Here is my program
package test;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.OperationClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.MessageContext;
public class Client {
public static void main(String[] args) throws Exception {
ServiceClient client = new ServiceClient();
OperationClient operationClient =
client.createClient(ServiceClient.ANON_OUT_IN_OP);
//creating message context
MessageContext outMsgCtx = new MessageContext();
//assigning message contexts option object into instance variable
Options opts = outMsgCtx.getOptions();
//setting properties into option
opts.setTo(new
EndpointReference("http://sws-challenge.org/shipper/v2/racer"));
opts.setAction("OrderOperation");
outMsgCtx.setEnvelope(creatSOAPEnvelope());
operationClient.addMessageContext(outMsgCtx);
System.out.println("message =" + creatSOAPEnvelope());
operationClient.execute(true);
MessageContext inMsgtCtx = operationClient.getMessageContext("In");
SOAPEnvelope response = inMsgtCtx.getEnvelope();
System.out.println(response);
}
public static SOAPEnvelope creatSOAPEnvelope() {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = fac.getDefaultEnvelope();
OMNamespace omNs =
fac.createOMNamespace("http://ws.apache.org/axis2/xsd", "q0");
OMElement method = fac.createOMElement("OrderOperationRequest", omNs);
OMElement value = fac.createOMElement("quantity", omNs);
OMElement value1 = fac.createOMElement("packageWeight", omNs);
value.addChild(fac.createOMText("1"));
value1.addChild(fac.createOMText("1"));
method.addChild(value);
method.addChild(value1);
OMElement value3 = fac.createOMElement("collectionTime", omNs);
OMElement value4 = fac.createOMElement("readyPickup", omNs);
value4.addChild(fac.createOMText("2007-08-22T10:50:30.051Z"));
OMElement value5 = fac.createOMElement("latestPickup", omNs);
value5.addChild(fac.createOMText("2007-08-24T10:50:33.934Z"));
value3.addChild(value4);
value3.addChild(value5);
method.addChild(value3);
envelope.getBody().addChild(method);
return envelope;
}
}
And I have such output after runing them:
message =<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><q0:OrderOperationRequest
xmlns:q0="http://ws.apache.org/axis2/xsd"><q0:quantity>1</q0:quantity><q0:packageWeight>1</q0:packageWeight><q0:collectionTime><q0:readyPickup>2007-08-22T10:50:30.051Z</q0:readyPickup><q0:latestPickup>2007-08-24T10:50:33.934Z</q0:latestPickup></q0:collectionTime></q0:OrderOperationRequest></soapenv:Body></soapenv:Envelope>
Exception in thread "main" org.apache.axis2.AxisFault: Data binding error
at
org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at test.Client.main(Client.java:31)
Here it's how looks like good one SOAP Request Envelope from web service
explorer:
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://www.example.org/racer/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <q0:OrderOperationRequest>
- <q0:from>
<q0:FirstName />
<q0:MiddleInitial />
<q0:LastName />
<q0:PhoneNumber />
<q0:Address1 />
<q0:City />
<q0:State />
<q0:ZipCode />
<q0:SpecialInstructions />
</q0:from>
- <q0:to>
<q0:FirstName />
<q0:LastName />
<q0:Address1 />
<q0:City />
<q0:State />
<q0:ZipCode />
<q0:Country>Argentina</q0:Country>
</q0:to>
<q0:quantity>1</q0:quantity>
<q0:packageWeight>1</q0:packageWeight>
- <q0:collectionTime>
<q0:readyPickup>2007-08-23T08:32:08.194Z</q0:readyPickup>
<q0:latestPickup>2007-08-25T08:32:12.270Z</q0:latestPickup>
</q0:collectionTime>
</q0:OrderOperationRequest>
</soapenv:Body>
</soapenv:Envelope
So what's wrong with my program ? I try to repair that through last few days.
Best regards,
Wojciech Zaremba
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]