none
Visual Studio 2013 Add Service Reference not working with SAS BI 9.4 webservice (SOAP 1.1) RRS feed

  • Question

  • Hi guys,

    I'm attempting to add a service reference for a simple SAS Hello World webservice but its producing an error everytime I attempt to add it.  I'm writing a test application in .Net 4.5. I've isolated the issue but am unsure how to proceed now.

    The webservice is a SOAP 1.1 service which is accessible through the browser and SOAP UI. However when I add it as a service reference (or a web reference in the advanced options) the following error is produced which seems to be visual studio treating it as a SOAP 1.2 service

    I have found this forum result  which is exactly whats happening (link) but I don't seem to have an option for .Net 4.5 WCF Activation just for 3.5.1 (I tried changing the application .Net framework to 3.5.1 to no avail)

    There was an error downloading 'http://xxxxxx.com:7980/SASBIWS/services/Products/SAS%20Intelligence%20Platform/Samples/Sample%3A%20Hello%20World?wsdl/_vti_bin/ListData.svc/$metadata'.
    The request failed with HTTP status 405: Method Not Allowed.
    Metadata contains a reference that cannot be resolved: 'http://xxxxxx.com:7980/SASBIWS/services/Products/SAS Intelligence Platform/Samples/Sample: Hello World?wsdl'.
    The content type text/xml;charset=UTF-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 793 bytes of the response were: '<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server</faultcode><faultstring>Could not access envelope: Disallowed element found inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Header; nested exception is org.apache.axiom.soap.SOAPProcessingException: Disallowed element found inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Header</faultstring><detail xmlns:fault="http://support.sas.com/xml/namespace/biwebservices/webservicemaker-9.2"><fault:Fault code="4000"><fault:Exception message="Disallowed element found inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Header"/></fault:Fault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>'.
    The remote server returned an error: (500) Internal Server Error.
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    I can provide more detail if necessary but I need to fix this on the Visual Studio side as the SAS system is beyond my control and the line from them is it works in the browser and SOAP UI. Thanks for your help


    Friday, May 15, 2015 8:30 AM

Answers

  • I found the answer!. It was a combination of issues, the wsdl was badly formed and some of the type and name attributes in it were preceeded with a space (HelloWorld2PortType, HelloWorld2SoapBinding and HelloWorld2Port. Then svcutil.exe would fail during code generation due to these spaces.

    After fixing these spaces the code generation worked properly but the call still failed, the reason for this is that the binding created after the code cgeneration in the app.config needed the binding to be specified as Mtom as Visual Studio doesn't take care of this automatically.

    <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="HelloWorld2SoapBinding" messageEncoding="Mtom" />
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://xxxx:980/SASBIWS/services/Shared data/ HelloWorld2"
            binding="basicHttpBinding" bindingConfiguration="HelloWorld2SoapBinding"
            contract="ServiceReference1.HelloWorld2PortType" name="HelloWorld2Port" />
        </client>
      </system.serviceModel>

    So the lesson I've learned here is to vigorously inspect the wsdl file and not assume it works because it does work in SOAP UI. The root of the problem was simply an space in a few attributes of the wsdl that apparently svcutil cant handle.  Hope this helps someone

    • Marked as answer by BrettLawless Wednesday, May 20, 2015 9:40 AM
    Wednesday, May 20, 2015 9:40 AM

All replies

  • Hi BrettLawless,

    Since your web service is a SOAP 1.1 service, then which binding are you using? I will recommand you use basicHttpBinding which defaults to SOAP 1.1 service.

    Besides, could you please try to post a simple reproduced project in here? I want to have a test in my Visual Studio 2013.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 18, 2015 5:31 AM
    Moderator
  • Hi Amy,

    Thanks for the reply. I have no control over the SAS webservice that has been installed. I have no bindings set in my project app.config because the issue exists with the "Add Service Reference" section of Visual Studio 2013.

    I'm only trying to add the webservice at this point and can't get that far as it errors out when I attempt to add it. Is it possible to add some sort of binding declaration to the app.config to make that part of Visual Studio behave? My understanding is that setting basicHttpBinding only affects projects that are WCF services. The project has no code at this point its a standard blank .NET 4.5 WPF Application that I'm trying to add the webservice too.

    Regards,

    Brett

    Monday, May 18, 2015 7:06 AM
  • I have some additional information which may help make more sense after analyzing this more. The SOAP 1.1 service is using MTOM. I was mistaken in thinking it was some sort of hybrid 1.1/1.2 SOAP service. So I think now the question is how do you add a SOAP 1.1 service with MTOM enabled as a service reference

    Regards,

    Brett


    Wednesday, May 20, 2015 8:03 AM
  • I found the answer!. It was a combination of issues, the wsdl was badly formed and some of the type and name attributes in it were preceeded with a space (HelloWorld2PortType, HelloWorld2SoapBinding and HelloWorld2Port. Then svcutil.exe would fail during code generation due to these spaces.

    After fixing these spaces the code generation worked properly but the call still failed, the reason for this is that the binding created after the code cgeneration in the app.config needed the binding to be specified as Mtom as Visual Studio doesn't take care of this automatically.

    <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="HelloWorld2SoapBinding" messageEncoding="Mtom" />
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://xxxx:980/SASBIWS/services/Shared data/ HelloWorld2"
            binding="basicHttpBinding" bindingConfiguration="HelloWorld2SoapBinding"
            contract="ServiceReference1.HelloWorld2PortType" name="HelloWorld2Port" />
        </client>
      </system.serviceModel>

    So the lesson I've learned here is to vigorously inspect the wsdl file and not assume it works because it does work in SOAP UI. The root of the problem was simply an space in a few attributes of the wsdl that apparently svcutil cant handle.  Hope this helps someone

    • Marked as answer by BrettLawless Wednesday, May 20, 2015 9:40 AM
    Wednesday, May 20, 2015 9:40 AM