views:

775

answers:

4

I'm having some major issues trying to consume my PHP SOAP webservice using ASP.NET. The webservice in question is based on the PHP SOAP extension and is descibed by the following WSDL:

<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="MyServices"
  targetNamespace="http://mydomain.com/api/soap/v11/services"
  xmlns:tns="http://mydomain.com/api/soap/v11/services"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsd1="http://mydomain.com/api/soap/v11/services"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns="http://schemas.xmlsoap.org/wsdl/"&gt;

<types>
    <schema targetNamespace="http://mydomain.com/api/soap/v11/services" xmlns="http://www.w3.org/2001/XMLSchema"&gt;
        <complexType name="ServiceType">
            <all>
                <element name="id" type="xsd:int" minOccurs="1" maxOccurs="1" />
                <element name="name" type="xsd:string" minOccurs="1" maxOccurs="1" />
                <element name="cost" type="xsd:float" minOccurs="1" maxOccurs="1" />
            </all>
        </complexType>
        <complexType name="ArrayOfServiceType">
            <all>
                <element name="Services" type="ServiceType" minOccurs="0" maxOccurs="unbounded" />
            </all>
        </complexType>
    </schema>
</types>


<message name="getServicesRequest">
    <part name="postcode" type="xsd:string" />
</message>

<message name="getServicesResponse">
  <part name="Result" type="xsd1:ArrayOfServiceType"/>
</message>

<portType name="ServicesPortType">
  <operation name="getServices">
    <input message="tns:getServicesRequest"/>
    <output message="tns:getServicesResponse"/>
  </operation>
</portType>

<binding name="ServicesBinding" type="tns:ServicesPortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
  <operation name="getServices">
    <soap:operation soapAction="http://mydomain.com/api/soap/v11/services/getServices" />
    <input>
      <soap:body use="encoded" namespace="urn:my:services" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
    </input>
    <output>
      <soap:body use="encoded" namespace="urn:my:services" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
    </output>
  </operation>
</binding>

<service name="MyServices">
  <port name="ServicesPort" binding="tns:ServicesBinding">
    <soap:address location="http://mydomain.com/api/soap/v11/services"/&gt;
  </port>
</service>
</definitions>

I can successfully generate a proxy class from this WSDL in Visual Studio, but upon trying to invoke the getServices method I am presented with an exception:

System.Web.Services.Protocols.SoapHeaderException: Procedure 'string' not present

After inspecting the raw post data at the SOAP server end, my PHP SOAP client is making requests like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
    <SOAP-ENV:Body>
        <postcode xsi:type="xsd:string">ln4 4nq</postcode>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Whereas the .Net proxy class is doing this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:tns="http://mydomain.com/api/soap/v11/services" 
    xmlns:types="http://mydomain.com/api/soap/v11/services/encodedTypes" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
        <xsd:string xsi:type="xsd:string">LN4 4NQ</xsd:string>
    </soap:Body>
</soap:Envelope>

I can only assume the difference in the way the postcode parameter is being sent is where the problem lies, but as primarily a PHP developer I'm at a loss as to what's occuring here. I have a feeling I'm simply missing something vital in my WSDL as I've seen countless examples of 'Consuming PHP SOAP WebServices with .Net' which appear to suggest that it 'just works'.

Any suggestion as to where i've slipped up here would be greatly appreciated. I've currently spent almost an entire day on this now ;-)

Thanks in advance,

Jamie

A: 

Dear Jamie

Have u been able to sort this issue out?

I am having similar issues where the .NET components returns a Fault saying "Badly Formatted Request" and as it turns out the PHP Soap call when calling a function actually sends "[pram1]value [/param1]" style request, while .NET proxy sends "[name]value[/name]" style parameter requests.

I have just began my research on this, I will contact u if I find something if u still need info on this.

Regards, Mrugendra Bhure.

Mrugendra Bhure
A: 

I'm having a very hard time even generating a proxy class for my PHP / WSDL soap service. I'm using Microsoft's Wsdl.exe as it's documented and it pops up a secondary window with some error message that is impossible to read before the window is closed. I'm using Vista Home edition? Should I switch back to XP / Professional? Any suggestions would be appreciated.

Chris Kaltwasser
A: 

I am having a similar problem as in .net just is not liking my php wsdl file how did you create that to work ?

Here I a example of my php wsdl generation

http://www.codingfriends.com/index.php/2010/04/12/soap-server/

any ideas and did you solve your problem ?

Genux
A: 

Hi There,

i am also Facing the same issue.

is any one found the solution..?

any help should be appreciated.

Thanks.

Dion