How do you accept PHP exceptions in a wsdl file?

I am not sure how to correctly make a fault element in a wsdl file repesenting a PHP exception.

I have created a PHP web service that throws an exception for testing purposes. When I call this web service in a test C# project, I get a reflection exception with the message "Item has already been added. Key in dictionary: 'System.Object' Key being added: 'System.Object'".

So this obviously means I have not created the fault element correctly in the wsdl file.


I don't know about PHP, or how obvious it is that you made a mistake in the creation of your fault element. Nor do I know what your wsdl or your php looks like, but here's an example of a wsdl with a fault message that works:

<?xml version="1.0"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
                  xmlns:tns="http://www.your.site/YourService"
                  targetNamespace="http://www.your.site/YourService"
                  name="ays">
    <xsd:import schemaLocation="http://www.your.site/YourService/AtYourService.xsd"
                namespace="http://www.your.site/YourService"/>
    <wsdl:message name="Input">
        <wsdl:part name="parameters"
                   element="tns:Question"/>
    </wsdl:message>

    <wsdl:message name="Output">
        <wsdl:part name="info"
                   element="tns:Answer"/>
    </wsdl:message>

    <wsdl:message name="Fault">
        <wsdl:part name="detail"
                   element="tns:FaultMessage"/>
    </wsdl:message>

    <wsdl:portType name="YourPortType">
        <wsdl:operation name="Question">
            <wsdl:input wsaw:Action="http://www.your.site/YourService/Question"
                        message="tns:Input"/>
            <wsdl:output wsaw:Action="http://www.your.site/YourService/Answer"
                         message="tns:Output"/>
            <wsdl:fault wsaw:Action="http://www.your.site/YourService/Fault"
                        name="QuestionFault"
                        message="tns:Fault"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="YourBinding"
                  type="tns:YourPortType">
        <wsdl:operation name="Question">
            <soap:operation soapAction="http://www.your.site/YourService/Question" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="QuestionFault">
                <soap:fault name="QuestionFault" use="literal"/>
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="YourService">
        <wsdl:port name="YourBinding" binding="tns:YourBinding">
            <soap:address location="http://www.your.site/YourService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

Regards, Miel.