none
ASP.Net Web Services and incoming XML request with Namespace Prefixes RRS feed

  • Question

  • Should be simple but not finding it to be:

    I have written a Service that returns a string value, the request contains two incoming parameters. An existing client is trying to call my service with an XML body that contains namespace prefixes for the top level return object - the string return.  When I publish, there are no prefixes in the XML example, and my service cannot extract the two parameters from the body.

    Here is what the existing client is sending -

    <?xml version="1.0" encoding="UTF-8"?>

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <soapenv:Body>

    <ns1:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://ecat.dmservices.co.uk">

    <a_sDMSUserName xsi:type="xsd:string">BRIINT0248/1</a_sDMSUserName>#

    <a_sDMSUserPassword xsi:type="xsd:string">xxxx</a_sDMSUserPassword></ns1:login>

    </soapenv:Body>

    </soapenv:Envelope>

    But the WSDL on publish states that the body should be -

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <login xmlns="http://ecat.dmservices.co.uk">
          <a_sDMSUserName>string</a_sDMSUserName>
          <a_sDMSUserPassword>string</a_sDMSUserPassword>
        </login>
      </soap:Body>
    </soap:Envelope>

    How do I make the WSDL enforce the "ns1" prefix for the method:

    public string login(string a_sDMSUSername, string a_sDMSUserPassword")

    {};

    Wednesday, May 7, 2014 9:31 AM

Answers

  • Hi,

    >>How do I make the WSDL enforce the "ns1" prefix for the method:

    For your scenario, you can try to use the MessageFormatter or the MessageEncoder, but it will recommand to use the MessageFormatter, and the following article has explained very well about how to implement your scenario, please try to check it:

    #Customize WCF Envelope and Namespace Prefix:
    http://vanacosmin.ro/Articles/Read/WCFEnvelopeNamespacePrefix .

    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.

    Thursday, May 8, 2014 9:33 AM
    Moderator