cancel
Showing results for 
Search instead for 
Did you mean: 

Fault Response Handling in Sync Interface

nidhi_srivastava22
Active Contributor
0 Kudos
Hi Experts,

We are expecting a Fault response as mentioned below, in case of any failure.

Interface is SAP ECC--> SAP PI --> SOAP(Sync)

<soapenv:Body>

<soapenv:Fault>

<Faultcode>Internal Server Error</Faultcode>

<Faultstring>Exception 8240986231</Faultstring>

</soapenv:Fault>

</soapenv:Body>

We are using the standard FaultMessage Structure shown below and XSLT mapping to extract and send to ECC but it is not working and we are getting transformation error when testing in Operation Mapping.

Error:- Transformer exception occurred when executing XSLT FaultMessage (urn:ariba.XXX, -1, 597a66f0-78b0-11e6-) error logs for detailsTransformer exception occurred when executing XSLT FaultMessage

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:template match="//soapenv:Fault">
<standard>
<faultText>
<xsl:value-of select="faultcode"/>
</faultText>
<faultDetail>
<text>
<xsl:value-of select="faultstring"/>
</text>
</faultDetail>
</standard>
</xsl:template>
</xsl:stylesheet>

I tried with normal one to one graphical mapping as well - there I am getting error related to soapenv prefixes in the fault response.Please suggest.

Thanks,

Nidhi Srivastava

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor

The problem here is that the XML response from the web service server is not valid XML.
I do not know if this is caused by the SAP PO adapter.
Could you test the web service using SOAP UI?

If the fault message is sent wrong from the server, there should be a fix on the server.

The correct Fault message should have a SOAP envelope:

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<SOAP:Fault>
<faultcode>SOAP:Server</faultcode>
<faultstring>Server Error</faultstring>
</SOAP:Fault>
</SOAP:Body>
</SOAP:Envelope>

If this is missing, it won't work.



Answers (3)

Answers (3)

peter_wallner2
Active Contributor
0 Kudos

Hello Nidhi Srivastava,

I tried both your "structure.txt" XMLs in an offline tool and came up with this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:soapenv="http://soapenv.sap"
    exclude-result-prefixes="soap xsd xsi soapenv"
    version="1.0">
    <xsl:template match="text()"/>
    
    <xsl:template match="/soap:Envelope/soap:Header/*[namespace-uri()='XXX' and local-name()='Headers']/*[namespace-uri()='XXX' and local-name()='partition']">
        <successPartition>
            <xsl:value-of select="."/>
        </successPartition>
    </xsl:template>
    
    <xsl:template match="soapenv:Body/soapenv:Fault/Faultcode">
        <errorResponse>
            <xsl:value-of select="."/>            
        </errorResponse>
    </xsl:template>
</xsl:stylesheet>

If I apply this to your 2 different XMLs I get this:

success message

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

error message

<?xml version="1.0" encoding="UTF-8"?>
<errorResponse>Internal Server Error</errorResponse>

Try it in Stefan Grube's page, it is working.

I hope that helps,
Peter

nidhi_srivastava22
Active Contributor
0 Kudos

Hi Peter,

Thanks for your help.

I tried testing through the XSLT provided by you, but I am getting the same error as before.

Thanks,

Nidhi Srivastava

peter_wallner2
Active Contributor
0 Kudos

Hi Nidhi Srivastava,

When I tested that XML I added this

xmlns:soapenv="http://soapenv.sap"
<soapenv:Body xmlns:soapenv="http://soapenv.sap">
    <soapenv:Fault>
        <Faultcode>Internal Server Error</Faultcode>
        <Faultstring>Error Description</Faultstring>
    </soapenv:Fault>
</soapenv:Body>

otherwise that XML will always show that error.

Could you provide the XSD for that ErrorMessages structure? Just click on tab "XSD" in your first screenshot. THanks, Peter

stefan_grube
Active Contributor
0 Kudos

You can find many online tools, for example:

https://www.freeformatter.com/xsl-transformer.html

I do not really understand: what is your input and your desired output?

nidhi_srivastava22
Active Contributor
0 Kudos

Hi Stefan,

The request is working fine, i have used addSoapEnvelope XSLT code to the structure as expected by the target.

The problem is coming in response. Actually, I have followed the below mentioned blog as the faultcode is coming as a response(system error and not application error).

https://blogs.sap.com/2015/07/29/soap-faults-and-webservice-faults-from-3rd-party-webservices/

As per the blog, I created the structure as mentioned in the screenshot below

Problem is the response and fault response coming from the target is in different format and I am unable to deal with the XSLT code.

In case of normal response - Envelope along with Header & Body is coming.Also, namespace prefix is coming as soap:

In case of Fault response - Only Body and Fault tag is coming along with the namespace prefix as soapenv:

The sample structure are attached for reference.

structure.txt

I tried forming the XSLT using the link you provided, it was very helpful. But, as I am beginner to XSLT coding am unable to format the correct structure in which both the structures can be handled.

Let me know if you have any suggestions.

Thanks,

Nidhi Srivastava

stefan_grube
Active Contributor
0 Kudos

The elements in your XSLT have different names as in your SOAP message. Element names are case sensitive.

Have you tested your XSLT with a tool outside SAP PO?

nidhi_srivastava22
Active Contributor
0 Kudos

Hi Stefan,

No Stefan I didn't tested outside PO, as installation of tools will take another 2-3 days.

But, I changed the names Faultcode and Faultstring and tested by that way as well.

Thanks,

Nidhi Srivastava