0

I have to develop a .NET API to a working php soap service, but I only have a WSDL file, that specifies the service attributes.

When I try to make a Service Reference in Visual Studio with the WSDL file it doesn't work, an error occurs:

"The content type text/plain 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. "

When I open the WSDL in Visual Studio, intellisense has a problem with <xs:sequence> in <types>, it says: "Namespace prefix 'xs' is not defined" - maybe there's something wrong here, but I don't speak WSDL....

Here is the WSDL file:

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

<definitions name="ProtopmailApiWorld"
         targetNamespace="urn:ProtopmailApiWorld"
         xmlns:tns="urn:ProtopmailApiWorld"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:API">
        <xsd:complexType name="arrayOfStrings">
            <xs:sequence>
                <xs:element name="TheStringValue" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xsd:complexType>
        <xsd:element name="outResponse" type="xsd:string" />
    </xsd:schema>
</types>

<message name="ApiSoap">
    <part name="params" type="tns:arrayOfStrings" />
</message>
<message name="ApiSoapResponse">
    <part name="return" type="tns:outResponse" />
</message>

<portType name="APIPort">
    <operation name="ApiSoap">
        <input message="tns:ApiSoap" />
        <output message="tns:ApiSoapResponse" />
    </operation>
</portType>

<binding name="APIBinding" type="tns:APIPort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="ApiSoap">
        <soap:operation soapAction="urn:ApiSoapAction" />
        <input>
            <soap:body use="encoded" namespace="urn:API" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
        </input>
        <output>
            <soap:body use="encoded" namespace="urn:API" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
        </output>
    </operation>
</binding>

<service name="ApiSoapService">
    <port name="APIPort" binding="tns:APIBinding">
        <soap:address location="https://website/api/soap.php" />
    </port>
</service>

Thanks

1 Answer 1

1

It is true that this WSDL is not valid since the xs prefix is not defined. To fix it add this definition:

xmlns:xs="http://www.w3.org/2001/XMLSchema"

somewhere on the first tag near the similar definitions.

regardeless I always recommend to first get a sample working soap (maybe from a php client, or the vendor) and then use C#.

EDIT: There were a few more problems with this wsdl - the namespace definition tns was different than the schema target namespace, so I arbitrarly chose one, and also the return type referes to an unknown type, so I changes it to string. try this:

<definitions name="ProtopmailApiWorld"
         targetNamespace="urn:ProtopmailApiWorld"
         xmlns:tns="urn:ProtopmailApiWorld"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:ProtopmailApiWorld">
        <xsd:complexType name="arrayOfStrings">
            <xs:sequence>
                <xs:element name="TheStringValue" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xsd:complexType>
        <xsd:element name="outResponse" type="xsd:string" />
    </xsd:schema>
</types>

<message name="ApiSoap">
    <part name="params" type="tns:arrayOfStrings" />
</message>
<message name="ApiSoapResponse">
    <part name="return" type="xsd:string" />
</message>

<portType name="APIPort">
    <operation name="ApiSoap">
        <input message="tns:ApiSoap" />
        <output message="tns:ApiSoapResponse" />
    </operation>
</portType>

<binding name="APIBinding" type="tns:APIPort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="ApiSoap">
        <soap:operation soapAction="urn:ApiSoapAction" />
        <input>
            <soap:body use="encoded" namespace="urn:API" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
        </input>
        <output>
            <soap:body use="encoded" namespace="urn:API" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
        </output>
    </operation>
</binding>

<service name="ApiSoapService">
    <port name="APIPort" binding="tns:APIBinding">
        <soap:address location="https://website/api/soap.php" />
    </port>
</service>
</definitions>
Sign up to request clarification or add additional context in comments.

4 Comments

thanks, now i can add the service reference. but i cannot create any variable to use it, is that even possible to use the php soap service with wcf this way? i mean there is no any endpoint definition here..
I now see this service is rpc/encoded. I recommend to use .net 2 client and not wcf, e.g. "add web reference" instead of "add service reference"
here is how to add web service reference webservices20.blogspot.co.il/2008/10/…
okay i did that, i called the webservice "ProtopmailWebservice", but i still cannot create any variable with that type (added the namespace correctly)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.