You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Manish Saha <Ma...@ivl.stpt.soft.net> on 2001/04/11 14:41:27 UTC
is there anybody over there
hi all,
this is a small program i tried work out based on sending a object as
parameter.
import java.net.*;
import java.util.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
public class HelloWorldClient {
public static final String DEFAULT_SERVICE_URL =
"http://ivlt13:7001/myapp1/rpcrouter";
public static void main(String args[])throws Exception{
MyName name=new MyName("manish");
SOAPMappingRegistry smr = new SOAPMappingRegistry();
BeanSerializer beanSer = new BeanSerializer();
System.out.println("BeanSer"+beanSer);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("urn:xml-soap-MyName-demo",
"MyName"),MyName.class,beanSer, beanSer);
URL url=new URL(DEFAULT_SERVICE_URL);
String urn="urn:helloworld";
Call call=new Call();
call.setTargetObjectURI(urn);
call.setMethodName("hello");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params=new Vector();
params.addElement(new
Parameter("MyName",MyName.class,name,null));
// MyName is a class which on both the server side and client (this
question i posted as to whether there should be class on both the server
and client side)
// there was no answer for that
call.setParams(params);
try{
System.out.println("invoke service\n"+"URL="+url+"\n
URN="+urn);
Response response =call.invoke(url,"");
if( !response.generatedFault())
{
Parameter result=response.getReturnValue();
System.out.println("Result="+result.getValue());
}
else
{
Fault f=response.getFault();
System.err.println("Fault="+f.getFaultCode());
}
}
catch(SOAPException e){
System.err.println("SOAPException="+e.getFaultCode()+","+e.getMessage());
}
}
}
MyName is a small class which follows the beans methodology.since apache
bean serlizer support this only.
public class MyName{
public String name;
public MyName(String name){
this.name=name;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public String toString(){
return name;
}
}
i get the following error message.
..........................SOAPException=SOAP-ENV:Client,No Serializer found
to serialize a 'MyName' using encoding style
'http://schemas.xmlsoap.org/soap/encoding/'.
and could tell me as to how to write our own bean serlizer.
---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org