none
How to get wsHttpBindings instead of basicHttpBindings when creating service reference? RRS feed

  • Question

  • Hi all,

    I am connecting to a java based webserver over which I have no control. I am writing a desktop app using VS 2010 in C#.

    When I try to use "add service reference" it works fine, but only produces code based on basicHttpBinding, NOT wsHttpBinding - which is what I want.  I do not see any option in the right-click-add Service Reference dialogs to specify the type of binding, but the web service requires that I send the user name and pw using the OASIS Standard 200401 protocol (user name and pw in the SOAP header).  I have been told that I need to implement wsHttpBindings in order for this to work. 

    Is there an easy way (yeah, right...) to change the bindings?  Say right clicking on something and choosing "change to wshttpbinding"? 

    If not, how do I create the service reference in a way that will create the desired bindings?  And if I really need to use a different binding for 200401, then would appreciate knowing that as well.

    Thanks


    me (and yes, I DO mark correct answers)

    Thursday, May 17, 2012 1:39 AM

Answers

  • the binding is determined by the WS-Policy tags (or lack of thereof) in the wsdl. WCF analyzed these tags (if exist) and decided that basicHttpBinding is the best bet. You should either change the config manually, or add the correct policy tags to the wsdl. I know you do not control the server - you could do this on the client side manually before the import. I would not recommend any of this - you should accept the wcf defaults or change them manually.

    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog

    • Proposed as answer by Sudhakar Kottapalli Friday, May 18, 2012 7:45 AM
    • Unproposed as answer by FletcherJ Friday, May 18, 2012 7:04 PM
    • Marked as answer by FletcherJ Friday, May 18, 2012 7:05 PM
    Thursday, May 17, 2012 5:48 PM

All replies

  • How is your service configuration file look like?

    have a look at the following article whether that helps

    http://www.codeproject.com/Articles/36396/Difference-between-BasicHttpBinding-and-WsHttpBind

    otherwise share your configuration settings.


    Tanvir Huda Application Architect/Consultant http://thetechnocrate.wordpress.com/

    Thursday, May 17, 2012 5:39 AM
  • Tanvir,

    I am talking to a web service over which I have no control.  It is written in Java.  I can see the wsdl.  When I right click on the project and choose Add Service Reference, it creates one using basicHttpBinding. 

    My question is, how do I get it to create one using wsHttpBinding?  My guess is that it is not doing so because it doesn't believe that the web service supports it and that there is no way for me to convince it otherwise. 

    I understand the difference between the 2 (and others as well.)  I just want to know why the add service reference insists on making it a basicHttpBinding, that's all.

    Is there something in the .wsdl file I can look for that might indicate the problem? I am not allowed to post the .wsdl file to the public.

    Thanks


    me (and yes, I DO mark correct answers)

    Thursday, May 17, 2012 7:06 AM
  • How do you develop you Java Web Service. There were some incompatiability between JAX-WS and .Net version of WSHttpBinding.

    You need to use WS-IT ...

    Are you sure Java Web Service is exposing WSHttpBinding


    Tanvir Huda Application Architect/Consultant http://thetechnocrate.wordpress.com/

    Thursday, May 17, 2012 7:20 AM
  • Tanvir,

    I have no control over the Java web service.  I am only writing the client.  The most information I can get is what is in the wsdl file.  But I am guessing from what you are saying that if the Java Web Service wsdl file doesn't specify any form of security in the wsdl file, then VS.NET will only create basicHttpBindings.

    Interesting.

    Thanks.


    me (and yes, I DO mark correct answers)

    Thursday, May 17, 2012 4:14 PM
  • hi,

    In App.Config change the Binding as follows to convert your service into wsHttpBinding

    <EndPoint Address="your address" Binding="WsHttpBinding" Contract="Iservice"/>


    PS.Shakeer Hussain

    Thursday, May 17, 2012 5:17 PM
  • the binding is determined by the WS-Policy tags (or lack of thereof) in the wsdl. WCF analyzed these tags (if exist) and decided that basicHttpBinding is the best bet. You should either change the config manually, or add the correct policy tags to the wsdl. I know you do not control the server - you could do this on the client side manually before the import. I would not recommend any of this - you should accept the wcf defaults or change them manually.

    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog

    • Proposed as answer by Sudhakar Kottapalli Friday, May 18, 2012 7:45 AM
    • Unproposed as answer by FletcherJ Friday, May 18, 2012 7:04 PM
    • Marked as answer by FletcherJ Friday, May 18, 2012 7:05 PM
    Thursday, May 17, 2012 5:48 PM
  • Yaron,

    Sorry for the confusing unpropose as answer stuff, but I HATE IT when someone comes along and decides a question is answered.  I guess that someone at MS feels that it is important that every question be answered. The problem is, most of the time when they do this, the reply they mark is not even close to an answer.  So I always unmark them and choose for myself if the question has been answered or not and which is the best.  For the first time while in msdn forums, the person actually got it right - somewhat of a surprise to me. 

    I think the confusing part of all this is that the people who control the web service use "OASIS Standard 200401" to pass the username and pw, but none of the associated encryption options, instead depending on https to manage the encryption. 

    Anyway, thanks for the help!


    me (and yes, I DO mark correct answers)

    Friday, May 18, 2012 7:12 PM