Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml-rpc server and failing client SOAP request

Status
Not open for further replies.

davemwi

Programmer
Oct 18, 2002
3
US
Ok, this question might cross some lines with php, soap and/or xml, but here we go.

I have setup an xml-rpc server with php. I've also created a wsdl to define the webservice calls. Many web service clients can consume the wsdl and make calls to the service which the xml-rpc server can handle. However, a .NET client composes it's soap envelope in such a way that the xml-rpc server misinterprets it. The reason the xml-rpc server cannot correctly interpret is is because of these soap envelope tags that the .NET client composes:
Code:
<soap:Envelope....>.....</soap:Envelope>
the server is expecting:
Code:
<SOAP-ENV:Envelope....>....</SOAP-ENV:Envelope>
and I've tested that fact. So my questions are, is the server incorrect in that it is restricted to those tags only around the envelope. Or, should the client be composing the request with the SOAP-ENV tags. Or, should my wsdl be formatted in a way so that the client knows it needs to use the SOAP-ENV tags (wsdl follows). I've seen many soap messages composed both ways and both ways are indicated to be 'correct'.

=============================
wsdl
=============================
Code:
<?xml version="1.0"?>
<definitions name="SOD"
    targetNamespace="urn:SOD"
    xmlns:typens="urn:SOD"
    xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL]
    xmlns:soap="[URL unfurl="true"]http://schemas.xmlsoap.org/wsdl/soap/"[/URL]
    xmlns:soapenc="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/"[/URL]
    xmlns:wsdl="[URL unfurl="true"]http://schemas.xmlsoap.org/wsdl/"[/URL]
    xmlns="[URL unfurl="true"]http://schemas.xmlsoap.org/wsdl/"[/URL] >

  <!-- Types for search - result elements, directory categories -->

  <types>
    <xsd:schema xmlns="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] 
        targetNamespace="urn:SOD">
            
      <xsd:complexType name="SODSearchResult">
        <xsd:all>
          <xsd:element name="documentFiltering" type="xsd:boolean"/>
          <xsd:element name="searchComments" type="xsd:string"/>
          <xsd:element name="estimatedTotalResultsCount" type="xsd:int"/>
          <xsd:element name="estimateIsExact" type="xsd:boolean"/>
          <xsd:element name="resultElements" type="typens:ResultElementArray"/>
          <xsd:element name="searchQuery" type="xsd:string"/>
          <xsd:element name="startIndex" type="xsd:int"/>
          <xsd:element name="endIndex" type="xsd:int"/>
          <xsd:element name="searchTips" type="xsd:string"/>
          <xsd:element name="directoryCategories" type="typens:DirectoryCategoryArray"/>
          <xsd:element name="searchTime" type="xsd:double"/>
        </xsd:all>
      </xsd:complexType>

      <xsd:complexType name="ResultElement">
        <xsd:all>
          <xsd:element name="summary" type="xsd:string"/>
          <xsd:element name="URL" type="xsd:string"/>
          <xsd:element name="snippet" type="xsd:string"/>
          <xsd:element name="title" type="xsd:string"/>
          <xsd:element name="cachedSize" type="xsd:string"/>
          <xsd:element name="relatedInformationPresent" type="xsd:boolean"/>
          <xsd:element name="hostName" type="xsd:string"/>
          <xsd:element name="directoryCategory" type="typens:DirectoryCategory"/>
          <xsd:element name="directoryTitle" type="xsd:string"/>
        </xsd:all>
      </xsd:complexType>
  
      <xsd:complexType name="ResultElementArray">
        <xsd:complexContent>
          <xsd:restriction base="soapenc:Array">
             <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ResultElement[]"/>
          </xsd:restriction>
        </xsd:complexContent>
      </xsd:complexType>

      <xsd:complexType name="DirectoryCategoryArray">
        <xsd:complexContent>
          <xsd:restriction base="soapenc:Array">
             <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:DirectoryCategory[]"/>
          </xsd:restriction>
        </xsd:complexContent>
      </xsd:complexType>

      <xsd:complexType name="DirectoryCategory">
        <xsd:all>
          <xsd:element name="fullViewableName" type="xsd:string"/>
          <xsd:element name="specialEncoding" type="xsd:string"/>
        </xsd:all>
      </xsd:complexType>

    </xsd:schema>
  </types> 

  <!-- Messages Web APIs -->
             
  <message name="method_call_in_question">
    <part name="username" type="xsd:string"/>
    <part name="password" type="xsd:string"/>
    <part name="xid" type="xsd:string"/>
  </message>

  <message name="method_call_in_questionResponse">
    <part name="return" type="xsd:base64Binary"/>
  </message>

  <!-- Port Web APIs, "SOD" -->

  <portType name="SODPort">
    <operation name="method_call_in_question">
      <input message="typens:method_call_in_question"/>
      <output message="typens:method_call_in_questionResponse"/>
    </operation>
  </portType>

  <!-- Binding for Web APIs - RPC, SOAP over HTTP -->

  <binding name="SODBinding" type="typens:SODPort">
    <soap:binding style="rpc" transport="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/http"/>[/URL]
    <operation name="method_call_in_question">
      <soap:operation style="rpc" soapAction="urn:SODAction"/>
      <input>
        <soap:body use="encoded"
                namespace="urn:SOD"
                encodingStyle="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/"/>[/URL]
      </input>
      <output>
        <soap:body use="encoded"
            namespace="urn:SOD"
            encodingStyle="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/"/>[/URL]
      </output>
    </operation>
  </binding>

  <!-- Endpoint-->
  <service name="SODService">
    <port name="SODPort" binding="typens:SODBinding">
      <soap:address location="[URL unfurl="true"]https://dev.endpoint.com/ws/"/>[/URL]
    </port>
  </service>

</definitions>
===============================
Unsuccessful Request: - fault string is: server error. method not found.
===============================
Code:
<soap:Envelope 
    xmlns:soap="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/"[/URL] 
    xmlns:soapenc="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/"[/URL] 
    xmlns:tns="urn:SOD" xmlns:types="urn:SOD/encodedTypes" 
    xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] 
    xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
    <soap:Body soap:encodingStyle="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/">[/URL]
        <tns:method_call_in_question>
            <username xsi:type="xsd:string">user</username>
            <password xsi:type="xsd:string">pass</password>
            <xid xsi:type="xsd:string">id</xid>
        </tns:method_call_in_question>
    </soap:Body>
</soap:Envelope>
============================================
Successful Request - only change is SOAP-ENV
============================================
Code:
<SOAP-ENV:Envelope 
    xmlns:soap="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/"[/URL] 
    xmlns:soapenc="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/"[/URL] 
    xmlns:tns="urn:SOD" xmlns:types="urn:SOD/encodedTypes" 
    xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] 
    xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
    <soap:Body soap:encodingStyle="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/encoding/">[/URL]
        <tns:method_call_in_question>
            <username xsi:type="xsd:string">user</username>
            <password xsi:type="xsd:string">pass</password>
            <xid xsi:type="xsd:string">id</xid>
        </tns:method_call_in_question>
    </soap:Body>
</SOAP-ENV:Envelope>

Thanks for any tips and suggestions.
 
.NET web proxies use doc-literal encoding by default. You can add the [SoapRpcMethodAttribute] attribute to your method, and specify Use=SoapBindingUse.Encoded as a parameter.

In the MSDN help, search on "Customizing SOAP Messages".

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks Chip. So is there any way in the wsdl to cause the .NET client to use the encoded binding style?
 
Not that I know of.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top