You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Avin <pe...@rediffmail.com> on 2005/04/21 00:04:02 UTC
driving me nuts - simple axis client
Hello Guys .....
This is driving me Nuts totally...
I am using Axis client to invoke a remotely hosted web-service at XMethods.
I've been sitting on this problem for the past 10 days .....still no clue
on it....
================================================================================
Here is my classpath setting:
C:\Soap>set
classpath=.;D:\Tomcat\webapps\axis\WEB-INF\lib\axis.jar;D:\Tomcat\we
bapps\axis\WEB-INF\lib\commons-discovery.jar;D:\Tomcat\webapps\axis\WEB-INF\lib\
commons-logging.jar;D:\Tomcat\webapps\axis\WEB-INF\lib\jaxrpc.jar;D:\Tomcat\weba
pps\axis\WEB-INF\lib\saaj.jar;D:\Tomcat\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar
;C:\activation.jar;C:\mail.jar;
================================================================================
Here is my code:
import org.apache.axis.client.Call;
import javax.xml.namespace.QName;
public class TemperatureServiceMain2
{
public static void main(String[] args) throws Exception
{
Call call = new
Call("http://services.xmethods.net:80/soap/servlet/rpcrouter");
// Set the name of the operation to call (from the portType in the WSDL)
// Note that we need to specify the namespace of the operation,
// also gleaned from the WSDL
call.setOperationName(new QName("urn:xmethods-Temperature", "getTemp"));
String zipCode = "19147"; // Zip code for Philadelphia
// Call the Web Service, passing the parameter as an array of Objects
// Similarly, the return value is a plain Object
Object ret = call.invoke(new Object[]{zipCode});
// Cast the return value to the correct type
float temp = ((Float)ret).floatValue();
System.out.println("The temperature at " + zipCode + " is " + temp);
}
}
==================================================================================
Here is what happens when I run the code:
================================================================================
C:\Soap>java TemperatureServiceMain2
log4j:WARN No appenders could be found for logger
(org.apache.axis.i18n.ProjectR
esourceBundle).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
faultSubcode:
faultString: No Deserializer found to deserialize a
'http://schemas.xmlsoap.org
/soap/encoding/:string' using encoding style
'http://schemas.xmlsoap.org/soap/en
coding/'.
faultActor: /soap/servlet/rpcrouter
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:No Deserializer found to
deseria
lize a 'http://schemas.xmlsoap.org/soap/encoding/:string' using encoding
style '
http://schemas.xmlsoap.org/soap/encoding/'.
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
.java:221)
at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
java:128)
at
org.apache.axis.encoding.DeserializationContext.endElement(Deserializ
ationContext.java:1087)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
at org.apache.crimson.parser.Parser2.parse(Unknown Source)
at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at
org.apache.axis.encoding.DeserializationContext.parse(Deserialization
Context.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at
org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.j
ava:745)
at
org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:141)
at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
at org.apache.axis.client.Call.invoke(Call.java:2737)
at org.apache.axis.client.Call.invoke(Call.java:2413)
at org.apache.axis.client.Call.invoke(Call.java:2336)
at org.apache.axis.client.Call.invoke(Call.java:1793)
at TemperatureServiceMain2.main(TemperatureServiceMain2.java:20)
{http://xml.apache.org/axis/}hostname:ISGDNARASIMAXP
No Deserializer found to deserialize a
'http://schemas.xmlsoap.org/soap/encoding
/:string' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.
at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
.java:221)
at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
java:128)
at
org.apache.axis.encoding.DeserializationContext.endElement(Deserializ
ationContext.java:1087)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
at org.apache.crimson.parser.Parser2.parse(Unknown Source)
at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at
org.apache.axis.encoding.DeserializationContext.parse(Deserialization
Context.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at
org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.j
ava:745)
at
org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:141)
at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
at org.apache.axis.client.Call.invoke(Call.java:2737)
at org.apache.axis.client.Call.invoke(Call.java:2413)
at org.apache.axis.client.Call.invoke(Call.java:2336)
at org.apache.axis.client.Call.invoke(Call.java:1793)
at TemperatureServiceMain2.main(TemperatureServiceMain2.java:20)
C:\Soap>
Re: driving me nuts - simple axis client
Posted by Jeff <je...@cogentlogic.com>.
By 'eck, lad, did yer not think 'o RTFM?
Avin, you must first build the client-side code using WSDL2Java then use
that code.
Check that D:/Tomcat/webapps/axis/WEB-INF/lib contains:
axis.jar;
axis-ant.jar;
commons-discovery.jar;
commons-logging.jar;
jaxrpc.jar;
junit3.7.jar;
log4j-1.2.8.jar;
saaj.jar;
wsdl4j.jar
Download this file:
http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl
into a working folder and open a command prompt on that folder.
Enter the command:
java.exe -classpath
.;D:/Tomcat/webapps/axis/WEB-INF/lib/axis.jar;D:/Tomcat/webapps/axis/WEB-INF
/lib/axis-ant.jar;D:/Tomcat/webapps/axis/WEB-INF/lib/bcprov-jdk14-121.jar;D:
/Tomcat/webapps/axis/WEB-INF/lib/commons-discovery.jar;D:/Tomcat/webapps/axi
s/WEB-INF/lib/commons-logging.jar;D:/Tomcat/webapps/axis/WEB-INF/lib/jaxrpc.
jar;D:/Tomcat/webapps/axis/WEB-INF/lib/junit3.7.jar;D:/Tomcat/webapps/axis/W
EB-INF/lib/log4j-1.2.8.jar;D:/Tomcat/webapps/axis/WEB-INF/lib/saaj.jar;D:/To
mcat/webapps/axis/WEB-INF/lib/wsdl4j.jar
org.apache.axis.wsdl.WSDL2Java --server-side --skeletonDeploy
true --timeout -1 --verbose --all --Debug --noWrapped --typeMappingVersion
1.2 DemoTemperatureService.wsdl > dump.txt
Inside newly generated net\xmethods\www\sd\TemperatureService_wsdl folder,
the files TemperatureBindingImpl.java and TemperatureBindingSkeleton.java
are server-side classes that can be discarded.
Create a Java project that include the generated classes (the net folder).
Add a test class that uses this code:
try
{
String zipCode = "19147"; // Zip code for Philadelphia
TemperatureServiceLocator locator = new TemperatureServiceLocator();
TemperatureBindingStub stub =
(TemperatureBindingStub)locator.getPort(TemperaturePortType.class);
float fTemp = stub.getTemp(zipCode);
System.out.println("The temperature at " + zipCode + " is " + fTemp);
}
catch (Exception except)
{
except.printStackTrace();
}
You will get the output:
The temperature at 19147 is 52.0
in accordance with the documentation that states that the legacy service is
hard-coded to return 52.0.
Warmest regards,
Jeff
----- Original Message -----
From: "Avin" <pe...@rediffmail.com>
To: <ax...@ws.apache.org>
Sent: Wednesday, April 20, 2005 6:04 PM
Subject: driving me nuts - simple axis client
> Hello Guys .....
>
> This is driving me Nuts totally...
> I am using Axis client to invoke a remotely hosted web-service at
XMethods.
> I've been sitting on this problem for the past 10 days .....still no clue
> on it....
>
>
============================================================================
====
> Here is my classpath setting:
>
> C:\Soap>set
> classpath=.;D:\Tomcat\webapps\axis\WEB-INF\lib\axis.jar;D:\Tomcat\we
>
bapps\axis\WEB-INF\lib\commons-discovery.jar;D:\Tomcat\webapps\axis\WEB-INF\
lib\
>
commons-logging.jar;D:\Tomcat\webapps\axis\WEB-INF\lib\jaxrpc.jar;D:\Tomcat\
weba
>
pps\axis\WEB-INF\lib\saaj.jar;D:\Tomcat\webapps\axis\WEB-INF\lib\log4j-1.2.8
.jar
> ;C:\activation.jar;C:\mail.jar;
>
>
============================================================================
====
>
> Here is my code:
>
> import org.apache.axis.client.Call;
> import javax.xml.namespace.QName;
> public class TemperatureServiceMain2
> {
> public static void main(String[] args) throws Exception
> {
>
> Call call = new
> Call("http://services.xmethods.net:80/soap/servlet/rpcrouter");
>
> // Set the name of the operation to call (from the portType in the WSDL)
> // Note that we need to specify the namespace of the operation,
> // also gleaned from the WSDL
> call.setOperationName(new QName("urn:xmethods-Temperature", "getTemp"));
>
> String zipCode = "19147"; // Zip code for Philadelphia
> // Call the Web Service, passing the parameter as an array of Objects
> // Similarly, the return value is a plain Object
> Object ret = call.invoke(new Object[]{zipCode});
>
> // Cast the return value to the correct type
> float temp = ((Float)ret).floatValue();
> System.out.println("The temperature at " + zipCode + " is " + temp);
> }
> }
>
>
============================================================================
======
> Here is what happens when I run the code:
>
============================================================================
====
> C:\Soap>java TemperatureServiceMain2
> log4j:WARN No appenders could be found for logger
> (org.apache.axis.i18n.ProjectR
> esourceBundle).
> log4j:WARN Please initialize the log4j system properly.
> Exception in thread "main" AxisFault
> faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
> faultSubcode:
> faultString: No Deserializer found to deserialize a
> 'http://schemas.xmlsoap.org
> /soap/encoding/:string' using encoding style
> 'http://schemas.xmlsoap.org/soap/en
> coding/'.
> faultActor: /soap/servlet/rpcrouter
> faultNode:
> faultDetail:
> {http://xml.apache.org/axis/}stackTrace:No Deserializer found to
> deseria
> lize a 'http://schemas.xmlsoap.org/soap/encoding/:string' using encoding
> style '
> http://schemas.xmlsoap.org/soap/encoding/'.
> at
> org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
> .java:221)
> at
> org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
> java:128)
> at
> org.apache.axis.encoding.DeserializationContext.endElement(Deserializ
> ationContext.java:1087)
> at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
> at org.apache.crimson.parser.Parser2.content(Unknown Source)
> at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
> at org.apache.crimson.parser.Parser2.content(Unknown Source)
> at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
> at org.apache.crimson.parser.Parser2.parseInternal(Unknown
Source)
> at org.apache.crimson.parser.Parser2.parse(Unknown Source)
> at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at
> org.apache.axis.encoding.DeserializationContext.parse(Deserialization
> Context.java:227)
> at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
> at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
> at
> org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.j
> ava:745)
> at
> org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:141)
>
> at
> org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
> y.java:32)
> at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
> at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
> at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
> at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
> at org.apache.axis.client.Call.invoke(Call.java:2737)
> at org.apache.axis.client.Call.invoke(Call.java:2413)
> at org.apache.axis.client.Call.invoke(Call.java:2336)
> at org.apache.axis.client.Call.invoke(Call.java:1793)
> at TemperatureServiceMain2.main(TemperatureServiceMain2.java:20)
>
> {http://xml.apache.org/axis/}hostname:ISGDNARASIMAXP
>
> No Deserializer found to deserialize a
> 'http://schemas.xmlsoap.org/soap/encoding
> /:string' using encoding style
'http://schemas.xmlsoap.org/soap/encoding/'.
> at
> org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
> .java:221)
> at
> org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
> java:128)
> at
> org.apache.axis.encoding.DeserializationContext.endElement(Deserializ
> ationContext.java:1087)
> at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
> at org.apache.crimson.parser.Parser2.content(Unknown Source)
> at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
> at org.apache.crimson.parser.Parser2.content(Unknown Source)
> at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
> at org.apache.crimson.parser.Parser2.parseInternal(Unknown
Source)
> at org.apache.crimson.parser.Parser2.parse(Unknown Source)
> at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at
> org.apache.axis.encoding.DeserializationContext.parse(Deserialization
> Context.java:227)
> at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
> at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
> at
> org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.j
> ava:745)
> at
> org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:141)
>
> at
> org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
> y.java:32)
> at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
> at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
> at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
> at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
> at org.apache.axis.client.Call.invoke(Call.java:2737)
> at org.apache.axis.client.Call.invoke(Call.java:2413)
> at org.apache.axis.client.Call.invoke(Call.java:2336)
> at org.apache.axis.client.Call.invoke(Call.java:1793)
> at TemperatureServiceMain2.main(TemperatureServiceMain2.java:20)
>
> C:\Soap>
>
>
>
>