cancel
Showing results for 
Search instead for 
Did you mean: 

Soap Axis Handler

Former Member
0 Kudos

Hello,

I tried to add custom handler in soap axis sender adapter to map soap fault response to another structure.

Pls see below code:

public class MapSoapResponse extends BasicHandler {

protected static Log log = LogFactory.getLog(MapSoapResponse.class.getName());

private static final String NSURI = "http://sap.com/xi/XI/System/Axis/sample";

private static final String LCNAME = "SimpleAuthentication";

/* (non-Javadoc)

  • @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)

*/

public void invoke(MessageContext msgContext) throws AxisFault {

try {

Message msg = msgContext.getCurrentMessage();

SOAPEnvelope soap = msg.getSOAPEnvelope();

if (soap.getBody().hasFault())

{soap.clearBody();

soap.addBodyElement(createSimpleAuthenticationHeader());}

else

soap.addBodyElement(createSimpleAuthenticationHeader());

}

catch (Exception e) {

Message msg = msgContext.getCurrentMessage();

SOAPEnvelope soap = msg.getSOAPEnvelope();

soap.clearBody();

try {

soap.addBodyElement(createSimpleAuthenticationHeader());

} catch (Exception e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

throw AxisFault.makeFault(e);

}

}

private SOAPBodyElement createSimpleAuthenticationHeader() throws Exception {

Document doc = XMLUtils.newDocument();

Element root = doc.createElementNS(NSURI, LCNAME);

Element nameNode = doc.createElementNS("", "name");

Text nameText = doc.createTextNode("");

nameNode.appendChild(nameText);

Element passwordNode = doc.createElementNS("", "password");

Text passwordText = doc.createTextNode("");

passwordNode.appendChild(passwordText);

root.appendChild(nameNode);

root.appendChild(passwordNode);

SOAPBodyElement body = new SOAPBodyElement(root);

return body;

}

}

The handler code gets executed if I have a timeout of 40sec in soap receiver adapter and I get following response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<Export>A</Export>

<ns1:SimpleAuthentication xmlns:ns1="http://sap.com/xi/XI/System/Axis/sample">

<name/>

<password/>

</ns1:SimpleAuthentication>

</soapenv:Body>

</soapenv:Envelope>

SimpleAuthentication is added by custom handler.

But if I have a timeout of 4 sec in soap receiver adapter and I get following response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<soapenv:Fault>

<faultcode>soapenv:Server.generalException</faultcode>

<faultstring>senderChannel 'bb92aea1ad2c38868e8aec4dff6c69cb': Catching exception calling messaging system; nested exception is:

com.sap.aii.af.ra.ms.api.DeliveryException: XIAdapterFramework:GENERAL:com.sap.aii.af.ra.ms.api.DeliveryException: Read timed out</faultstring>

<detail>

<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">sapxis01</ns1:hostname>

</detail>

</soapenv:Fault>

</soapenv:Body>

</soapenv:Envelope>

Here, custom handler is not clearing out the body and adding SimpleAuthentication element in the body.

I was expecting following output in this case:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<ns1:SimpleAuthentication xmlns:ns1="http://sap.com/xi/XI/System/Axis/sample">

<name/>

<password/>

</ns1:SimpleAuthentication>

</soapenv:Body>

</soapenv:Envelope>

Any Ideas?

Please help.

Am I missing something or is there any alternative?

Thanks in advance,

Beena.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Beena,

I think both of your posted messages contain no line breaks and I cannot read your messages with certainty.

I don't know exactly what you want to do and how your code looks.

I am not sure if anyone else is having the same problem of reading your messages. If you suspect that your messages were not posted correctly, please repost your messages correctly formatted.

So far I read that you want your code to be called for the fault case. In this case, you have to implement the onFault method and not the invoke method. The invoke method is for the normal request/response processing. Whenever some fault occurs, the onFault methods of the preceding handlers are called in the reverse order.

Refer to the online documentation.

http://ws.apache.org/axis/java/architecture-guide.html#HandlersAndChains

Regards, Yza

Former Member
0 Kudos

Hi

Not look like you missed something.

Whats the default timeout you have. The value should not be less then the default value.

Thanks

Gaurav

Former Member
0 Kudos

Hi Gaurav,

I am giving timeout in XMBWS.Timeout in soap receiver adapter.

I want to check the scenario where I will get timeout from receiver and map the soap fault message generated to another structure in module and send it to sender application.

But I am not sure whether this will work or not?

It seems adapter framework throws error which is catched by axis framework but the framework is not calling the handlers.

Please see audit log below for both the scenarios:

Timeout:

Success The message status set to DLNG.

2008-10-13 11:21:52 Error Received XI System Error. ErrorCode: GENERAL ErrorText: com.sap.aii.af.ra.ms.api.DeliveryException: Read timed out ErrorStack:

2008-10-13 11:21:52 Error Returning synchronous error notification to calling application: com.sap.aii.af.ra.ms.api.DeliveryException: XIAdapterFramework:GENERAL:com.sap.aii.af.ra.ms.api.DeliveryException: Read timed out.

2008-10-13 11:21:52 Error Transmitting the message using connection http://sapxis01:8000/sap/xi/engine?type=entry failed, due to: com.sap.aii.af.ra.ms.api.DeliveryException: XIAdapterFramework:GENERAL:com.sap.aii.af.ra.ms.api.DeliveryException: Read timed out.

2008-10-13 11:21:52 Error The message status set to FAIL.

2008-10-13 11:21:52 Error Returning to application. Exception: com.sap.aii.af.ra.ms.api.DeliveryException: XIAdapterFramework:GENERAL:com.sap.aii.af.ra.ms.api.DeliveryException: Read timed out

2008-10-13 11:21:52 Error MP: Exception caught with cause com.sap.aii.af.ra.ms.api.DeliveryException: XIAdapterFramework:GENERAL:com.sap.aii.af.ra.ms.api.DeliveryException: Read timed out

2008-10-13 11:21:52 Error Axis: error caused by com.sap.aii.af.ra.ms.api.DeliveryException: XIAdapterFramework:GENERAL:com.sap.aii.af.ra.ms.api.DeliveryException: Read timed out

No Timeout:

Success The message status set to DLNG.

2008-10-13 11:21:56 Success The application sent the message synchronously using connection SOAP_http://sap.com/xi/XI/System. Returning to application.

2008-10-13 11:21:56 Success The message was successfully transmitted to endpoint http://sapxis01:8000/sap/xi/engine?type=entry using connection SOAP_http://sap.com/xi/XI/System.

2008-10-13 11:21:56 Success The message status set to DLVD.

2008-10-13 11:21:56 Success MP: Processing local module localejbs/AF_Adapters/axis/AFAdapterBean

2008-10-13 11:21:56 Success MP: Processing local module localejbs/AF_Adapters/axis/HandlerBean

2008-10-13 11:21:56 Success MP: Processing local module localejbs/AF_Adapters/axis/HandlerBean

2008-10-13 11:21:56 Success MP: Leaving module processor

2008-10-13 11:21:56 Success Axis: returning from the module processor for channel soap_axis_sender

Thanks,

Beena.

Former Member
0 Kudos

HI

Do you guys have step by step implementation procesdure for soap axis handler.Please share the links