You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by Alpa <aj...@cs.columbia.edu> on 2002/06/26 17:46:24 UTC
Need urgent help with serialization problem
Hi,
I have a simple .NET webservice that has 2 methods. Both methods return
a string but one takes an integer and the other takes a string.
I have written a apache soap client to access the service.
When i try to invoke the method that takes int, it works fine. BUT it
does not for the method that takes the string.
Is it a problem with the serializers? This is the fault i receive:
Fault Code = soap:Server
Fault String = Server was unable to process request. --> Object
reference not set to an instance of an object.
Could someone please help !
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
This is the code for it
import org.apache.soap.encoding.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.rpc.*;
import org.apache.soap.*;
import java.util.*;
import java.net.*;
class RMT {
static String XMLSOAP = "http://schemas.xmlsoap.org/soap/encoding/";
static String __targetNS = "http://tempuri.org/";
static String __methNsURI = __targetNS;
static String __baseURL = "http://160.39.201.12/Simple/simple.asmx";
static String __soapAction = "http://tempuri.org/SimpleInput";
static String __methodName = "SimpleInput";
// static String __methodName = "SimpleMethod";
// static String __soapAction = "http://tempuri.org/SimpleMethod";
public static void main(String args[]) throws Exception {
Call call = new Call();
SOAPMappingRegistry smr = new SOAPMappingRegistry();
StringDeserializer mySer = new StringDeserializer();
smr.mapTypes(XMLSOAP, new QName(__targetNS, "SimpleInputResult"),
String.class, null, mySer);
call.setSOAPMappingRegistry(smr);
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setTargetObjectURI(__methNsURI);
call.setMethodName(__methodName);
Vector params = new Vector();
params.addElement(new Parameter("strInput", String.class, "Test",
null));
// params.addElement(new Parameter("intInput", int.class, new
Integer(555), null));
call.setParams(params);
URL url = new URL(__baseURL);
Response res = call.invoke(url, __soapAction);
if (res.generatedFault()) {
Fault f = res.getFault();
System.out.println("Fault Code = " + f.getFaultCode());
System.out.println("Fault String = " + f.getFaultString());
} else {
Parameter p = res.getReturnValue();
System.out.println(" Object Value = " + p.getValue());
}
}
}
~Alpa
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>
Re: Need urgent help with serialization problem
Posted by Scott Nichol <sn...@scottnichol.com>.
Alpa,
Are you a computer science student asking someone to finish your work? :-)
I think the problem is
smr.mapTypes(XMLSOAP, new QName(__targetNS, "SimpleInputResult"),
String.class, null, mySer);
since this registers null as a string serializer. Try this instead
smr.mapTypes(XMLSOAP, new QName(__targetNS, "SimpleInputResult"), null,
null, mySer);
This registers the deserializer just for the QName you specify.
Scott Nichol
----- Original Message -----
From: "Alpa" <aj...@cs.columbia.edu>
To: <so...@xml.apache.org>
Sent: Wednesday, June 26, 2002 11:46 AM
Subject: Need urgent help with serialization problem
> Hi,
> I have a simple .NET webservice that has 2 methods. Both methods return
> a string but one takes an integer and the other takes a string.
> I have written a apache soap client to access the service.
> When i try to invoke the method that takes int, it works fine. BUT it
> does not for the method that takes the string.
> Is it a problem with the serializers? This is the fault i receive:
>
> Fault Code = soap:Server
> Fault String = Server was unable to process request. --> Object
> reference not set to an instance of an object.
>
> Could someone please help !
>
>
>
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////
>
> This is the code for it
>
> import org.apache.soap.encoding.*;
> import org.apache.soap.util.xml.*;
> import org.apache.soap.rpc.*;
> import org.apache.soap.*;
> import java.util.*;
> import java.net.*;
>
> class RMT {
>
> static String XMLSOAP = "http://schemas.xmlsoap.org/soap/encoding/";
> static String __targetNS = "http://tempuri.org/";
> static String __methNsURI = __targetNS;
> static String __baseURL = "http://160.39.201.12/Simple/simple.asmx";
> static String __soapAction = "http://tempuri.org/SimpleInput";
> static String __methodName = "SimpleInput";
> // static String __methodName = "SimpleMethod";
> // static String __soapAction = "http://tempuri.org/SimpleMethod";
>
> public static void main(String args[]) throws Exception {
> Call call = new Call();
> SOAPMappingRegistry smr = new SOAPMappingRegistry();
>
> StringDeserializer mySer = new StringDeserializer();
> smr.mapTypes(XMLSOAP, new QName(__targetNS, "SimpleInputResult"),
> String.class, null, mySer);
>
> call.setSOAPMappingRegistry(smr);
> call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> call.setTargetObjectURI(__methNsURI);
> call.setMethodName(__methodName);
>
> Vector params = new Vector();
> params.addElement(new Parameter("strInput", String.class, "Test",
> null));
> // params.addElement(new Parameter("intInput", int.class, new
> Integer(555), null));
> call.setParams(params);
>
> URL url = new URL(__baseURL);
> Response res = call.invoke(url, __soapAction);
> if (res.generatedFault()) {
> Fault f = res.getFault();
> System.out.println("Fault Code = " + f.getFaultCode());
> System.out.println("Fault String = " + f.getFaultString());
> } else {
> Parameter p = res.getReturnValue();
> System.out.println(" Object Value = " + p.getValue());
> }
> }
> }
>
>
> ~Alpa
>
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@xml.apache.org>
> For additional commands, e-mail: <ma...@xml.apache.org>
>
>
Re: Need urgent help with serialization problem
Posted by Scott Nichol <sn...@scottnichol.com>.
Alpa,
Are you a computer science student asking someone to finish your work? :-)
I think the problem is
smr.mapTypes(XMLSOAP, new QName(__targetNS, "SimpleInputResult"),
String.class, null, mySer);
since this registers null as a string serializer. Try this instead
smr.mapTypes(XMLSOAP, new QName(__targetNS, "SimpleInputResult"), null,
null, mySer);
This registers the deserializer just for the QName you specify.
Scott Nichol
----- Original Message -----
From: "Alpa" <aj...@cs.columbia.edu>
To: <so...@xml.apache.org>
Sent: Wednesday, June 26, 2002 11:46 AM
Subject: Need urgent help with serialization problem
> Hi,
> I have a simple .NET webservice that has 2 methods. Both methods return
> a string but one takes an integer and the other takes a string.
> I have written a apache soap client to access the service.
> When i try to invoke the method that takes int, it works fine. BUT it
> does not for the method that takes the string.
> Is it a problem with the serializers? This is the fault i receive:
>
> Fault Code = soap:Server
> Fault String = Server was unable to process request. --> Object
> reference not set to an instance of an object.
>
> Could someone please help !
>
>
>
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////
>
> This is the code for it
>
> import org.apache.soap.encoding.*;
> import org.apache.soap.util.xml.*;
> import org.apache.soap.rpc.*;
> import org.apache.soap.*;
> import java.util.*;
> import java.net.*;
>
> class RMT {
>
> static String XMLSOAP = "http://schemas.xmlsoap.org/soap/encoding/";
> static String __targetNS = "http://tempuri.org/";
> static String __methNsURI = __targetNS;
> static String __baseURL = "http://160.39.201.12/Simple/simple.asmx";
> static String __soapAction = "http://tempuri.org/SimpleInput";
> static String __methodName = "SimpleInput";
> // static String __methodName = "SimpleMethod";
> // static String __soapAction = "http://tempuri.org/SimpleMethod";
>
> public static void main(String args[]) throws Exception {
> Call call = new Call();
> SOAPMappingRegistry smr = new SOAPMappingRegistry();
>
> StringDeserializer mySer = new StringDeserializer();
> smr.mapTypes(XMLSOAP, new QName(__targetNS, "SimpleInputResult"),
> String.class, null, mySer);
>
> call.setSOAPMappingRegistry(smr);
> call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> call.setTargetObjectURI(__methNsURI);
> call.setMethodName(__methodName);
>
> Vector params = new Vector();
> params.addElement(new Parameter("strInput", String.class, "Test",
> null));
> // params.addElement(new Parameter("intInput", int.class, new
> Integer(555), null));
> call.setParams(params);
>
> URL url = new URL(__baseURL);
> Response res = call.invoke(url, __soapAction);
> if (res.generatedFault()) {
> Fault f = res.getFault();
> System.out.println("Fault Code = " + f.getFaultCode());
> System.out.println("Fault String = " + f.getFaultString());
> } else {
> Parameter p = res.getReturnValue();
> System.out.println(" Object Value = " + p.getValue());
> }
> }
> }
>
>
> ~Alpa
>
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@xml.apache.org>
> For additional commands, e-mail: <ma...@xml.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>