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 Patrick <pb...@idevco.com> on 2004/04/04 00:56:05 UTC
Errors in Axis 1.1 for code that works in 1.2a
I'm developing an client using Axis (the web service is written in .NET
and I have no control over it). I can get the call to work with Axis
1.2 alpha, but the same code will not work with Axis 1.1. The reason I
need to use 1.1 is because I'm going to be calling this from Cold
Fusion, and I'm only able to append things to the classpath (that is,
the CFusion server will use the 1.1 classes and I cannot get around this).
I've been searching thru this mailing list archive, and here is what
I've come up with thusfar:
First, how it works in 1.2a. I run the WSDL2Java against the wsdl
(http://services.resx.com/xapi/test/xapi.asmx?wsdl), and then wrote this
code:
------------------------------
String url = wsdl;
String action = "http://services.resx.com/xapi/v1.0/xapi/ProfileRead";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(url) );
call.setOperationStyle(org.apache.axis.enum.Style.WRAPPED);
call.setOperationUse(org.apache.axis.enum.Use.LITERAL);
call.setSOAPActionURI(action);
call.setUseSOAPAction(true);
call.setOption(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, new
Boolean(false));
call.setOperationName(new
QName("http://services.resx.com/xapi/v1.0/xapi/", "ProfileRead"));
call.addParameter(new
QName("http://services.resx.com/xapi/v1.0/xapi/","oCredentials"),org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new
QName("http://services.resx.com/xapi/v1.0/xapi/","iProfileID"),org.apache.axis.Constants.XSD_INT,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(new QName("http://services.resx.com/xapi/v1.0/xapi/",
"Profile"));
call.setReturnClass(com.resx.services.xapi.v1_0.xapi.Profile.class);
call.setReturnQName(new
QName("http://services.resx.com/xapi/v1.0/xapi/", "ProfileReadResult"));
Object[] params = {oCredentials, iProfileID};
oProfile = (Profile)(call.invoke(params));
------------------------------
That works great, the object gets deserialized and I end up with an
object of type Profile which I can then work with. If I run the
WSDL2Java included with Axis 1.1 compile everything against the 1.1
classes and execute it, The call to setReturnClass seems to be voiding
out the setReturnType and I get the warning:
- No returnType was specified to the Call object! You must call
setReturnType() if you have called addParameter().
along with an error (child element NOT expected). So I comment out the
call to setReturnClass, and compile and execute it, and that gives me:
org.xml.sax.SAXException: Deserializing parameter 'ProfileReadResult':
could not find deserializer for type
{http://services.resx.com/xapi/v1.0/xapi/}Profile
Searching the axis-user list archive, I saw a post about using
call.registerTypeMapping, so if I add that, the code now looks like:
------------------------------
call.setReturnType(new QName("http://services.resx.com/xapi/v1.0/xapi/",
"Profile"));
//call.setReturnClass(com.resx.services.xapi.v1_0.xapi.Profile.class);
call.setReturnQName(new
QName("http://services.resx.com/xapi/v1.0/xapi/", "ProfileReadResult"));
call.registerTypeMapping(com.resx.services.xapi.v1_0.xapi.Profile.class,
new QName("http://services.resx.com/xapi/v1.0/xapi/", "Profile"),
BeanSerializerFactory.class, BeanDeserializerFactory.class);
Object[] params = {oCredentials, iProfileID};
oProfile = (Profile)(call.invoke(params));
------------------------------
And the error I get is:
org.xml.sax.SAXException: SimpleDeserializer encountered a child
element, which is NOT expected, in something it was trying to deserialize.
Two things to note:
1) No matter which version of the code I use from above, the SOAP
delivered back from the server looks fine in TCPMonitor.
2) I've seen people talking about adding something to the .wsdd file.
Since I'm not creating a web service, I do not have a wsdd. WSDL2Java
does not create one either (I'm new to web services, so I'm not sure if
it's suppose to or not).
Anyone know what I'm doing wrong? Any help you can give me is greatly
appreciated.
Sincerely,
Patrick