[Xml-compile] returning a fault in XML::Compile::SOAP::HTTPDaemon
Mark Overmeer
mark at overmeer.net
Fri Mar 12 09:26:57 GMT 2010
* Pete Groff (pfg104 at gmail.com) [100302 18:37]:
> I have the fault below defined in my WSDL:
> <xsd:element name="createIdentity_fault">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="createIdentity_fault_code"
> type="xsd:string" maxOccurs="1" minOccurs="1">
> </xsd:element>
> <xsd:element name="createIdentity_fault_details"
> type="xsd:string" maxOccurs="1" minOccurs="1">
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> <wsdl:message name="createIdentity_faultMsg">
> <wsdl:part name="fault" element="tns:createIdentity_fault"></wsdl:part>
> </wsdl:message>
>
> <wsdl:portType name="eSP">
> <wsdl:operation name="createIdentity">
> <wsdl:input message="tns:createIdentityRequest"/>
> <wsdl:output message="tns:createIdentityResponse"/>
> <wsdl:fault name="createIdentity_faultMsg" message=
> "tns:createIdentity_faultMsg"></wsdl:fault>
> </wsdl:operation>
> </wsdl:portType>
> <wsdl:binding name="eSPSOAP" type="tns:eSP">
> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/
> http"/>
> <wsdl:operation name="createIdentity">
> <wsdl:input>
> <soap:body use="literal"/>
> </wsdl:input>
> <wsdl:output>
> <soap:body use="literal"/>
> </wsdl:output>
> <wsdl:fault name="createIdentity_faultMsg">
> <soap:fault name="createIdentity_faultMsg" use="literal"></
> soap:fault>
> </wsdl:fault>
> </wsdl:operation>
>
> How do I return createIdentity_faultMsg? What should the hash look like or am
> I limited to returning faults like this?
>
> return { Fault =>
> { faultcode => pack_type(SOAP11ENV, 'Server.invalidResponse')
> , faultstring => 'I dont know man'
>
> , faultactor => 'database_exists'
> } };
>
It took me a while to understand what is happening, but the answer
is quite short.
Usually, when you call the translator from Perl into XML for
SOAP, the syntax is like this:
$call->(part1 => \%data1, part2 => \%data2);
The "part1" and "part2" are the part names as defined by the WSDL.
However, when you have only one body part, then you have an abbeviation:
$call->(%data1);
For faults, there is no such abbreviation. Your fault part name is
'fault' The content element of the "detailed" section is specified to
be createIdentity_fault. It contains createIdentity_fault_code and
createIdentity_fault_details.
What your handler routine should return is
+{ fault => # part name of the fault: small 'f'
{ faultcode => pack_type(SOAP11ENV, 'Server.invalidResponse')
, faultstring => 'I dont know man'
, faultactor => 'database_exists' # this is not an actor! SOAP11NEXT
, detail =>
{ createIdentity_fault_code => '1234'
, createIdentity_fault_details => 'boom!'
}
}
};
Hope that helps. I'll document it.
--
Regards,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark at Overmeer.net solutions at overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net
More information about the Xml-compile
mailing list