9 Replies Latest reply on Jan 25, 2011 3:49 PM by Gsahoo-Oracle

    sending soap fault response from a WSDL proxy service

    Gsahoo-Oracle
      Hi All,
      I have a WSDL based proxy service. I am expecting if a message comes with incorrect format according to w3c addressing protocol, it will generate a soap fault automatically. But it looks like it does not do that.
      It just returns errorcode 500- Internal server error. Do I need to build soap fault in system error handler to be returned as part of a error response?
      In the proxy I also check for a specific element in the soap header and if not present I raise error. This error also go to system error handler attached to the proxy. I am using reply with failure in the system error handler . I need this error to be returned as a soap fault to the external caller of this proxy service but It does not return any soap fault, returning only the error code.

      If I need to build the soap fault then what variable should I populate to return this to the caller? fault variable or body variable?
      I need to send both the http response code and soap fault to the caller.

      Please suggets
        • 1. Re: sending soap fault response from a WSDL proxy service
          Eric Elzinga
          Testcase i did

          wsdl service with http transport, business service endpoint is down.
          The osb generates this soap fault for me.
          <soapenv:Envelope      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
          <soapenv:Body>
          <soapenv:Fault>
          <faultcode>soapenv:Server</faultcode>
          <faultstring>BEA-380002: Not Found</faultstring>
          <detail>
          <con:fault      xmlns:con="http://www.bea.com/wli/sb/context">
          <con:errorCode>BEA-380002</con:errorCode>
          <con:reason>Not Found</con:reason>
          <con:location>
          <con:node>RouteNode_....Proxy</con:node>
          <con:path>response-pipeline</con:path>
          </con:location>
          </con:fault>
          </detail>
          </soapenv:Fault>
          </soapenv:Body>
          </soapenv:Envelope>
          if you want to construct your own soap fault details you can try something like this :
          http://www.xenta.nl/blog/2010/07/17/oracle-service-bus-11g-handling-soap-faults/
          1 person found this helpful
          • 2. Re: sending soap fault response from a WSDL proxy service
            Gsahoo-Oracle
            My test case is as below external service 1-> HTTP WSDL proxy ->Q provider ->Q-> Q consumer ->http biz service->external service 2

            I want to send fault to external service 1 if they have not passed certain elements in the soap header or message is not compliant to wc3 protocol. I do not want to pass this message to Q or external service 2 here.

            Here is what I am doing currently in my proxy service

            1) In the HTTP WSDL proxy service message flow I check for few element s ( elements that are required according our business protocol) in the soap header
            2) if not present raise error
            3) in service error handler attached to this proxy service, I catch it, build a soap fault, then replace $body with this soap fault message
            4) I used "reply with failure " to send back the fault

            i tried running a scenario that generated this fault message but the fault message was not returned/responded back to the external service 1. it receives only 500-internal server error code. I tried from SoapUI too with no luck. Am I missing anything?
            Do I need to add fault element to WSDL to make it work(somewhere I see in OTN forum about this)? I do not think so..

            Please suggest


            I am using soap 1.2 protocol osb11g here.

            Edited by: 818591 on Jan 20, 2011 4:55 AM

            Edited by: 818591 on Jan 20, 2011 4:57 AM
            • 3. Re: sending soap fault response from a WSDL proxy service
              687626
              in service error handler attached to this proxy service, I catch it, build a soap fault, then replace $body with this soap fault message
              Are you building the soap fault in soap 1.2 format? There are some significant changes in element names within soap:fault in soap1.2. What could be happening is osb is passsing the fault in 1.1 format but the soap 1.2 client runtime at ext service 1 is not able to interpret it as a fault.


              Hit google on soap 1.2 fault structure and you can see many links explaining the difference from 1.1
              http://www.google.com.au/#sclient=psy&hl=en&q=soap+1.2+soap+fault+structure&aq=f&aqi=&aql=&oq=&pbx=1&fp=73c7bc053ca04fbd
              1 person found this helpful
              • 4. Re: sending soap fault response from a WSDL proxy service
                Gsahoo-Oracle
                Yes, I am building soap fault in soap 12 format
                I have OSB tracing on for this component here is what it is printing in the log file. This is in soap12 format

                [OSB Tracing] The following variables are changed:
                $body = <env:Body xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:pf-naming="urn:pf:trust:naming/2010/05">
                <env:Fault>
                <env:Code>
                <env:Value>env:Sender</env:Value>
                <env:Subcode>
                <env:Value>pf-naming:MissingRegionOrEndpointIdentifier</env:Value>
                </env:Subcode>
                </env:Code>
                <env:Reason>
                <env:Text xml:lang="en-US">Missing or incorrect value provided in the SOAP header</env:Text>
                </env:Reason>
                </env:Fault>
                </env:Body>

                There are other variables are getting printed too, in case it will help in figuring out the issue, I am providing those here



                Message Context = [MessageContextImpl  body="<env:Body xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:pf-naming="urn:pf:trust:naming/2010/05">
                  <env:Fault>
                    <env:Code>
                      <env:Value>env:Sender</env:Value>
                      <env:Subcode>
                        <env:Value>pf-naming:MissingRegionOrEndpointIdentifier</env:Value>
                      </env:Subcode>
                    </env:Code>
                    <env:Reason>
                      <env:Text xml:lang="en-US">Missing or incorrect value provided in the SOAP header</env:Text>
                    </env:Reason>
                  </env:Fault>
                </env:Body>"
                operation="addRequest"
                messageID="1753715945626250942-27bf29de.12da8c7fc84.-7fd6"
                attachments="<con:attachments xmlns:con="http://www.bea.com/wli/sb/context"/>"
                outbound="<con:endpoint name="BusinessService$userProvisioning$businessService$SimpleProvider" xmlns:con="http://www.bea.com/wli/sb/context">
                  <con:service/>
                  <con:transport>
                    <con:mode>request-response</con:mode>
                    <con:qualityOfService>best-effort</con:qualityOfService>
                    <con:request xsi:type="jms:JmsRequestMetaData" xmlns:jms="http://www.bea.com/wli/sb/transports/jms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                      <tran:headers xsi:type="jms:JmsRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports"/>
                      <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">UTF-8</tran:encoding>
                    </con:request>
                  </con:transport>
                  <con:security>
                    <con:doOutboundWss>false</con:doOutboundWss>
                  </con:security>
                </con:endpoint>"
                fault="null"
                inbound="<con:endpoint name="ProxyService$userProvisioning$proxyService$ProvisioningReqListener" xmlns:con="http://www.bea.com/wli/sb/context">
                  <con:service>
                    <con:operation>addRequest</con:operation>
                  </con:service>
                  <con:transport>
                    <con:uri>/userProvisioning/ProvisioningReqListener</con:uri>
                    <con:mode>request</con:mode>
                    <con:qualityOfService>best-effort</con:qualityOfService>
                    <con:request xsi:type="http:HttpRequestMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                      <tran:headers xsi:type="http:HttpRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
                        <http:Accept-Encoding>gzip,deflate</http:Accept-Encoding>
                        <http:Content-Length>329</http:Content-Length>
                        <http:Content-Type>application/soap+xml;charset=UTF-8;action="Provisioning_addRequest"</http:Content-Type>
                        <http:Host>LPF004689.north.pf.com:7001</http:Host>
                        <http:User-Agent>Jakarta Commons-HttpClient/3.1</http:User-Agent>
                      </tran:headers>
                      <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">UTF-8</tran:encoding>
                      <http:client-host>LPF004689.north.pf.com</http:client-host>
                      <http:client-address>10.40.252.98</http:client-address>
                      <http:http-method>POST</http:http-method>
                    </con:request>
                    <con:response xsi:type="http:HttpResponseMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                      <tran:headers xsi:type="http:HttpResponseHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
                        <http:Content-Type>application/soap+xml</http:Content-Type>
                      </tran:headers>
                      <tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">1</tran:response-code>
                    </con:response>
                  </con:transport>
                  <con:security>
                    <con:transportClient>
                      <con:username>&lt;anonymous></con:username>
                    </con:transportClient>
                  </con:security>
                </con:endpoint>"
                header="<soap:Header xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="urn:pf:trust:provisioning/2010/05"/>"
                ]>

                Thanks for help and time..
                • 5. Re: sending soap fault response from a WSDL proxy service
                  Gsahoo-Oracle
                  Could someone suggest if I need to add fault element to the WSDL of the proxy service to make it work?

                  My MEP is in-only. But if there is a validation failure I need to send fault back to the caller. Since it is in-only I do not have any output parameter fir the operations in WSDL
                  Any example of wsdl with in-only operation with fault will be very helpful.
                  • 6. Re: sending soap fault response from a WSDL proxy service
                    687626
                    You can try with adding fault. Can you test if the below wsdl sample with in+fault only works for your case.
                      <wsdl:portType name="GetEndorsingBoarderPortType">
                        <wsdl:operation name="GetEndorsingBoarder">
                          <wsdl:input message="es:GetEndorsingBoarderRequest"/>
                          <wsdl:fault message="es:GetEndorsingBoarderFault"/>
                        </wsdl:operation>
                      </wsdl:portType>
                    
                       <wsdl:binding name="EndorsementSearchSoapBinding"
                                    type="es:GetEndorsingBoarderPortType">
                       <soap:binding style="document"
                                      transport="http://schemas.xmlsoap.org/soap/http"/>
                    
                       
                        <wsdl:operation name="GetEndorsingBoarder">
                          <wsdl:input>
                            <soap:body use="literal"
                                 namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
                          </wsdl:input>
                          <wsdl:fault>
                            <soap:body use="literal"
                                 namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
                          </wsdl:fault>
                        </wsdl:operation>
                      </wsdl:binding>
                    • 7. Re: sending soap fault response from a WSDL proxy service
                      Gsahoo-Oracle
                      Could you please send me the whole wsdl ?
                      I mean with namespace declaration, message part, type..

                      BTW, not sure if adding fault element without output element being declared will be accepted or not.

                      I started with the below simple wsdl with one operation and it is not in valid state, complaining as below

                      Expected element 'output@http://schemas.xmlsoap.org/wsdl/' instead of 'fault@http://schemas.xmlsoap.org/wsdl/' here in element operation@http://schemas.xmlsoap.org/wsdl/ at userProvisioning.wsdl


                      ?xml version="1.0" encoding="UTF-8"?>
                      <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:voyager="urn:pf:trust:Voyager/2010/05" xmlns:prov="urn:pf:trust:provisioning/2010/05" xmlns:inf="urn:pf:trust:inf-extension/2010/05" xmlns:tns="urn:pf:trust:Voyager:wsdl-v1" xmlns:icrs-fault="urn:pf:icrs:faults/2010/05" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:imports="urn:pf:trust:VoyagerWS/2010/05/Imports" xmlns:wsa10="http://www.w3.org/2005/08/addressing" name="voyager-provisioning-wsdl-v1.wsdl" targetNamespace="urn:pf:trust:Voyager:wsdl-v1">
                           <wsdl:import namespace="http://docs.oasis-open.org/wsrf/bfw-2" location="bfw-2.wsdl"/>
                           <wsdl:types>
                                <xs:schema targetNamespace="urn:pf:trust:VoyagerWS/2010/05/Imports" elementFormDefault="qualified" xmlns:imports="urn:pf:trust:VoyagerWS/2010/05/Imports">
                                     <xs:import namespace="urn:pf:trust:Voyager/2010/05" schemaLocation="voyager-0.9.xsd"/>
                                     <xs:import namespace="urn:pf:trust:provisioning/2010/05" schemaLocation="core-types-0.9.xsd"/>
                                     <xs:import namespace="urn:pf:icrs:faults/2010/05" schemaLocation="icrs-faults-0.9.xsd"/>
                                
                                

                      </xs:schema>
                                
                           </wsdl:types>
                                
                      <wsdl:message name="addRequest_InputMessage">
                                <wsdl:part name="parameter" element="prov:addRequest"/>
                           </wsdl:message>
                           <wsdl:message name="modifyRequest_InputMessage">
                                <wsdl:part name="parameter" element="prov:modifyRequest"/>
                           </wsdl:message>
                           
                           <wsdl:message name="compositeRequest_InputMessage">
                                <wsdl:part name="parameter" element="prov:compositeRequest"/>
                           </wsdl:message>
                           
                           <wsdl:message name="provFault">
                      <wsdl:part name="parameter" type="xs:string"/>
                      </wsdl:message>
                           
                           <wsdl:portType name="Provisioning">
                                
                                <wsdl:operation name="addRequest">
                                     <wsdl:input message="tns:addRequest_InputMessage"/>
                                
                                <wsdl:fault name ="provFault" message="tns:provFault"/>
                                
                                     </wsdl:operation>
                                     
                           </wsdl:portType>
                           
                           <wsdl:binding name="ProvisioningService" type="tns:Provisioning">
                                <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
                           <wsdl:operation name="addRequest">
                                     <soap12:operation soapAction="Provisioning_addRequest"/>
                                     <wsdl:input>
                                          <soap12:body use="literal"/>
                                     </wsdl:input>
                                
                                     
                                     <wsdl:fault name="provFault" >
                                     <soap12:body use="literal"/>
                                     </wsdl:fault>
                                </wsdl:operation>
                                
                                     
                           </wsdl:binding>

                           <wsdl:service name="ProvisioningService">
                                <wsdl:port name="Provisioning" binding="tns:ProvisioningService">
                                     <soap12:address location="No Target Adress"/>
                                </wsdl:port>
                           </wsdl:service>

                      </wsdl:definitions>

                      Edited by: 818591 on Jan 24, 2011 8:24 AM
                      • 8. Re: sending soap fault response from a WSDL proxy service
                        687626
                        The wsdl in the above post is wrong..apologies.. I couldnt test it before posting..

                        May be you can try this approach .

                        Define a message 'empty' with no parts to it and denote the output message to be of type 'empty'

                        <definitions ...>

                        *<message name="empty"/>*
                        <message name="InsufficientFundsFault">
                        <part name="balance" type="xsd:int"/>
                        </message>

                        <portType name="Bank">
                        <operation name="FundBalance">
                        <input message="tns:FundBalanceRequest"/>
                        *<output message="tns:empty"/>*
                        <fault name="fault" message="tns:InsufficientFundFault"/>
                        </operation>
                        </portType>
                        ...
                        </definitions>
                        1 person found this helpful
                        • 9. Re: sending soap fault response from a WSDL proxy service
                          Gsahoo-Oracle
                          This trick worked. I will have to check our interface and protocol definition to see if this is acceptable or not.