hi,
i am new to
webservices and axis2.
have started off
with the guides and samples from the axis2 distribution.
my requirement is to
write webservice clients (connecting to .net webservices) and not
webservices themselves.
i am trying to put
together a very simple client to connect to the google spell checker service. i
dont need an user interface like the one in the samples.
i have written
something like the following..
---------------------------------------------------------------------------------
private void
testEchoBlocking(String word){
try {
org.apache.axis2.addressing.EndpointReference targetEPR = new org.apache.axis2.addressing.EndpointReference(new java.net.URL(protocol, googleEndPoint, googleServiceName).toString());
org.apache.axis2.om.OMElement payload = getElement(word);
org.apache.axis2.client.Options options = new org.apache.axis2.client.Options();
options.setTo(targetEPR);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
try {
org.apache.axis2.addressing.EndpointReference targetEPR = new org.apache.axis2.addressing.EndpointReference(new java.net.URL(protocol, googleEndPoint, googleServiceName).toString());
org.apache.axis2.om.OMElement payload = getElement(word);
org.apache.axis2.client.Options options = new org.apache.axis2.client.Options();
options.setTo(targetEPR);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTP);
//Blocking
invocation
org.apache.axis2.client.ServiceClient sender = new org.apache.axis2.client.ServiceClient();
sender.setOptions(options);
org.apache.axis2.om.OMElement result = sender.sendReceive(payload);
org.apache.axis2.client.ServiceClient sender = new org.apache.axis2.client.ServiceClient();
sender.setOptions(options);
org.apache.axis2.om.OMElement result = sender.sendReceive(payload);
java.io.StringWriter writer = new
java.io.StringWriter();
result.serialize(javax.xml.stream.XMLOutputFactory.newInstance().createXMLStreamWriter(writer));
writer.flush();
result.serialize(javax.xml.stream.XMLOutputFactory.newInstance().createXMLStreamWriter(writer));
writer.flush();
System.out.println(writer.toString());
}
catch (Exception e)
{
e.printStackTrace();
}
e.printStackTrace();
}
-------------------------------------------------------------------------------------
when i run it from
inside idea like ->
C:/j2sdk1.4.2_02\bin\java
-Daxis2.home=C:\Implementations\axis\axis2-std-0.94-bin
-Dfile.encoding=windows-1252 -classpath
"C:\j2sdk1.4.2_02\jre\lib\charsets.jar;C:\j2sdk1.4.2_02\jre\lib\jce.jar;C:\j2sdk1.4.2_02\jre\lib\jsse.jar;C:\j2sdk1.4.2_02\jre\lib\plugin.jar;C:\j2sdk1.4.2_02\jre\lib\rt.jar;C:\j2sdk1.4.2_02\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_02\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_02\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_02\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_02\jre\lib\ext\sunjce_provider.jar;C:\Sybase\EAServer\java\classes;C:\Implementations\axis\axis2-std-0.94-bin\lib\wstx-asl-2.8.1.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\maven-itest-plugin-1.0.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\axis2-adb-0.94.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\annogen-0.1.0.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\axis2-codegen-0.94.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\commons-codec-1.3.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\XmlSchema-SNAPSHOT.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\geronimo-spec-javamail-1.3.1-rc5.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\xbean-2.1.0.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\axis2-core-0.94.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\xercesImpl-2.7.1.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\stax-api-1.0.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\geronimo-spec-activation-1.0.2-rc4.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\axis-wsdl4j-1.2.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\commons-httpclient-3.0.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\backport-util-concurrent-2.0_01_pd.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\commons-logging-1.0.4.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\servletapi-2.3.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\ws-policy-SNAPSHOT.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\geronimo-spec-jms-1.1-rc4.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\xml-apis-1.3.02.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\axis2-doom-0.94.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\log4j-1.2.12.jar;C:\Implementations\axis\axis2-std-0.94-bin\lib\jaxen-1.1-beta-7.jar;C:\Program
Files\IntelliJ-IDEA-4.0.3\lib\idea_rt.jar" -Didea.launcher.port=7539
"-Didea.launcher.library=C:\Program Files\IntelliJ-IDEA-4.0.3\bin\breakgen.dll"
com.intellij.rt.execution.application.AppMain
sapphire.custom.axis.TestClient
i get an error like
->
- Deploying module :
addressing
org.apache.axis2.AxisFault: Axis2 transport error : Length Required; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Length Required; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Length Required; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Length Required
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:245)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:449)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:317)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:267)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:393)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:326)
at sapphire.custom.axis.TestClient.testEchoBlocking(TestClient.java:112)
at sapphire.custom.axis.TestClient.main(TestClient.java:31)
org.apache.axis2.AxisFault: Axis2 transport error : Length Required; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Length Required; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Length Required; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Length Required
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:245)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:449)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:317)
at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:267)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:393)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:326)
at sapphire.custom.axis.TestClient.testEchoBlocking(TestClient.java:112)
at sapphire.custom.axis.TestClient.main(TestClient.java:31)
what am i doing
wrong ? i am quite wretched that i cannot get my first code to
run.
i dont understand
why the samples work fine, but my code doesn't. all that i have done is copy
pasted from the samples.
shuvro..