Hi Chamikara,
I checkout the axis2 last version and I keep your code corrected.
Your code works but if I change the test : "if (sequenceReport!=null &&
sequenceReport.getCompletedMessages().size()==1)" and not 3.
I think it's ok for this one.
Now I want to do the same thing not Anonymous but Addressable. I modify
your code to do that. Can you try it? And tell me if it works for you.
Because I meet a "Class not Found" on HTTPService. This class was
present in a precedent version of axis2.
Really thanks for your help.
Regards
Elodie
Chamikara Jayalath wrote:
Hi Elodie,
See my comments below.
On 8/4/06, *Mancinelli Elodie* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi Chamikara,
I tested your client MTOMPingClient and it didn't terminate
because the
variable "complete" never taked its value to true.
This was due to a mistake. I corrected the code. It should terminate
properly now.
Like the client
didn't receive the server's response.
In TCPMon, I can see these messages:
- Create Sequence and its response
- Message with the acknowledgement
- Terminate Sequence, and the OK
Markers ReplyTo and AcksTo equal to
http://www.w3.org/2005/08/addressing/anonymous
<http://www.w3.org/2005/08/addressing/anonymous>
To execute the client, I take the mar which is generate in the target
repository. But I can't take the generates jars because they make me
this error:
- Deploying module : soapmonitor
- Deploying module : addressing
- Deploying module : sandesha2
- StandardWrapper.Throwable
java.lang.NoSuchMethodError:
org.apache.axis2.i18n.Messages.addMessageBundle(Ljava/lang/String;Lorg/apache/axis2/i18n/MessageBundle;)V
at
org.apache.sandesha2.i18n.SandeshaMessageHelper.innit(SandeshaMessageHelper.java:36)
at
org.apache.sandesha2.SandeshaModule.init(SandeshaModule.java:56)
On this error, you tell me to check out the last version of mar
because
I have the last version.
With a precedent version of jars, the error disappears.
You seems to be using an old axis2 version. Please take a latest Axis2
checkout and build the webapp.
Do you know why thid test "if (sequenceReport!=null &&
sequenceReport.getCompletedMessages ().size()==3)" is never past ?
Thanks a lot to help me.
Elodie
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package sandesha2.samples.userguide;
import java.awt.Image;
import java.io.File;
import java.io.FileInputStream;
import javax.activation.DataHandler;
import javax.xml.namespace.QName;
import org.apache.axiom.attachments.utils.ImageDataSource;
import org.apache.axiom.attachments.utils.ImageIO;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContextConstants;
import org.apache.sandesha2.client.SandeshaClient;
import org.apache.sandesha2.client.SandeshaClientConstants;
import org.apache.sandesha2.client.SandeshaListener;
import org.apache.sandesha2.client.SequenceReport;
import org.apache.sandesha2.util.SandeshaUtil;
import fr.gouv.finances.dgme.presto.PrestoWSRM_MTOMtest.TestCallback;
public class MTOMPingClient {
private static final String applicationNamespaceName = "http://tempuri.org/";
private static final String MTOMPing = "MTOMPing";
private static final String Text = "Text";
private String toIP = "127.0.0.1";
private String toPort = "8080";
private String transportToPort = "8070";
private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMSampleService";
private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMSampleService";
private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator; //this will be available after a maven build
public static void main(String[] args) throws AxisFault {
String axisClientRepo = null;
if (args!=null && args.length>0)
axisClientRepo = args[0];
if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
AXIS2_CLIENT_PATH = axisClientRepo;
SANDESHA2_HOME = "";
}
new MTOMPingClient ().run();
}
private void run () throws AxisFault {
if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
return;
}
String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
Options clientOptions = new Options ();
clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
clientOptions.setTo(new EndpointReference (toEPR));
String sequenceKey = SandeshaUtil.getUUID();// "sequence2";
clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
// clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1); //uncomment this to send the messages according to the v1_1 spec.
// clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
ServiceClient serviceClient = new ServiceClient (configContext,null);
serviceClient.engageModule(new QName ("sandesha2"));
clientOptions.setAction("urn:wsrm:Ping");
// Add properties Addressable
String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
clientOptions.setUseSeparateListener(true);
serviceClient.setOptions(clientOptions);
clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
// Change to Addressable
Callback callback1 = new TestCallback ("Callback 1");
serviceClient.sendReceiveNonBlocking(getPingOMBlock(),callback1);
// serviceClient.fireAndForget(getPingOMBlock());
SandeshaClient.waitUntilSequenceCompleted(serviceClient);
serviceClient.finalizeInvoke();
}
private static OMElement getPingOMBlock() throws AxisFault {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
OMElement pingElem = fac.createOMElement(MTOMPing, namespace);
OMElement attachmentElem = fac.createOMElement("Attachment", namespace);
Image image;
String imageName = "test-resources" + File.separator + "mtom-image.jpg";
ImageDataSource dataSource;
try {
image = new ImageIO().loadImage(new FileInputStream(imageName));
dataSource = new ImageDataSource("test.jpg",image);
} catch (Exception e) {
throw new AxisFault (e);
}
DataHandler dataHandler = new DataHandler(dataSource);
OMText textData = fac.createOMText(dataHandler, true);
attachmentElem.addChild(textData);
pingElem.addChild(attachmentElem);
return pingElem;
}
static class TestCallback extends Callback {
String name = null;
public TestCallback (String name) {
this.name = name;
}
public void onComplete(AsyncResult result) {
// Traitement du résultat et affichage
System.out.println("\nResult :");
System.out.println("Callback '" + name + "' got result:" + result.getResponseEnvelope());
}
public void onError (Exception e) {
System.out.println("Error reported for test call back");
e.printStackTrace();
}
}
private class SandeshaListenerImpl implements SandeshaListener {
public void onError(AxisFault fault) {
System.out.println("*********** RM fault callbak called");
}
public void onTimeOut(SequenceReport report) {
System.out.println("Sequence timed out");
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]