方法
* 「XxxxXxxxMessageReceiverInOut」クラスの「invokeBusinessLogic」メソッドの
引数「org.apache.axis2.context.MessageContext msgContext」の
「msgContext.getEnvelope().toString()」で取得可能
SOAPレスポンスの取得方法
* 「XxxxXxxxMessageReceiverInOut」クラスの「invokeBusinessLogic」メソッド内の
「toEnvelope()」の戻り値「org.apache.axiom.soap.SOAPEnvelope envelope」を
「envelope.toString()」で取得可能
サンプル
* 教材として、以下の関連記事のサンプルを使用する
http://blogs.yahoo.co.jp/dk521123/34134786.html
HelloWorldServiceMessageReceiverInOut.java
* 「★追加」の一行だけ
public class HelloWorldServiceMessageReceiverInOut extends
org.apache.axis2.receivers.AbstractInOutMessageReceiver {
public void invokeBusinessLogic(
org.apache.axis2.context.MessageContext msgContext,
org.apache.axis2.context.MessageContext newMsgContext)
throws org.apache.axis2.AxisFault {
try {
//★追加
System.out.println();
System.out.println("[SOAP Request Log] "
+ msgContext.getEnvelope().toString());
// get the implementation class for the Web Service
Object obj = getTheImplementationObject(msgContext);
HelloWorldServiceSkeletonInterface skel = (HelloWorldServiceSkeletonInterface) obj;
//Out Envelop
org.apache.axiom.soap.SOAPEnvelope envelope = null;
//Find the axisOperation that has been set by the Dispatch phase.
org.apache.axis2.description.AxisOperation op = msgContext
.getOperationContext().getAxisOperation();
if (op == null) {
throw new org.apache.axis2.AxisFault(
"Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider");
}
java.lang.String methodName;
if ((op.getName() != null)
&& ((methodName = org.apache.axis2.util.JavaUtils
.xmlNameToJavaIdentifier(op.getName().getLocalPart())) != null)) {
if ("sayHello".equals(methodName)) {
com.sample.SayHelloResponse sayHelloResponse7 = null;
com.sample.SayHello wrappedParam = (com.sample.SayHello) fromOM(
msgContext.getEnvelope().getBody().getFirstElement(),
com.sample.SayHello.class,
getEnvelopeNamespaces(msgContext.getEnvelope()));
sayHelloResponse7 = skel.sayHello(wrappedParam);
envelope = toEnvelope(getSOAPFactory(msgContext),
sayHelloResponse7, false, new javax.xml.namespace.QName(
"http://helloworld.webservice.moodykettle.com",
"sayHello"));
} else {
throw new java.lang.RuntimeException("method not found");
}
newMsgContext.setEnvelope(envelope);
//★追加
System.out.println();
System.out.println("[SOAP Response Log] " + envelope.toString());
}
} catch (java.lang.Exception e) {
throw org.apache.axis2.AxisFault.makeFault(e);
}
}