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 siddharth aggarwal <si...@rediffmail.com> on 2001/09/13 12:39:38 UTC
problem with custom parameters
Hi,
I want to trnasfer some custom parameters using apache SOAP RPC.I was trying to transfer a Vector.
My client code looks like.
// file Client.java
package dbcustom;
public class Client
{
public static void main(String[] args) throws Exception
{
URL url=new URL(args[0]); // Address of SOAP router
String[] strArray = new String[2];
Vect vect=new Vect(); // my custom parameter
vect.v.addElement(args[1]);
vect.v.addElement(args[2]);
SOAPMappingRegistry registry = new SOAPMappingRegistry( );
BeanSerializer serializer = new BeanSerializer( );
registry.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("urn:Vect-demo", "p"),
Vector.class, serializer, serializer);
Call call=new Call();
call.setSOAPMappingRegistry(registry);
call.setSOAPMappingRegistry(new SOAPMappingRegistry());
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setTargetObjectURI("urn:DBCUSTOM");
call.setMethodName("searchList");
Vector params=new Vector();
params.addElement(new Parameter("vect",Vect.class,
vect,null));
call.setParams(params);
Response resp = null;
try {resp = call.invoke(url, "");
}
catch( SOAPException e )
{ System.err.println("Caught SOAPException (" + e.getFaultCode() + "): " + e.getMessage());
System.exit(-1);
}
}
}
My server code looks like.
// file Server.java
package dbcustom;
public class Server
{
public String searchList(Vect v)
{
String param1=v.v.elementAt(0).toString(); String param2 = v.v.elementAt(1).toString();
return param1+param2;
}
}
And I have a 3rd file on the server side which contains definition for my custom type Vect.
// file Vect.java
package dbcustom;
import java.util.*;
public class Vect
{
Vector v;
}
My doubts:
1)How should I register my custom type (I am using Tomcat server3.1.1) and am graphically deploying my services?
2)I am a little doubtful about the client side code.
especially the line:
registry.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("urn:Vect-demo", "p"),
where i have used urn:Vect-demo
3)I am getting an null pointer exception in the Client.java statement
vect.v.addElement(args[1]);
4) Does Vect.java really have to be in the same package i.e. dbcustom as the server class.
I would be grateful if somebody could send me a code sample in which a custom parameter has been used and deployed. I don't think I am even deploying my service in the right way (though i have had success deploying services without custom parameters).
Regards,
Siddharth