开发者

Spring returning custom soap faults

开发者 https://www.devze.com 2023-01-22 22:05 出处:网络
I am using spring webservices to expose my services as web services. I defined my Soap fault element like this

I am using spring webservices to expose my services as web services. I defined my Soap fault element like this

<xsd:element name="systemFault">
        <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="faultCode" type="xsd:string" nillable="true"/>
                    <xsd:element name="faultMessage" type="xsd:string"/>
                </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

and I am using this in my WSDL

<wsdl开发者_运维知识库:message name="msgSystemFault">
        <wsdl:part name="body" element="cred:SystemFault"/>
    </wsdl:message>

and then use this in an operation

<wsdl:operation name="opMyOp">
            <wsdl:documentation>
                Creating an entity note.
            </wsdl:documentation>
            <wsdl:input message="tns:msgMyOpRequest"/>
            <wsdl:output message="tns:msgMyOpResponse"/>
            <wsdl:fault name="fault" message="tns:msgSystemFault"/>
        </wsdl:operation>

But when I want to throw this fault in my endpoint, how can I do that??


You need a EndpointExceptionResolver, see SpringWS manual about handling exceptions.

SpringWS comes with some built-in exception resolves, you can use those as a reference when implementing your own.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号