Problem with first SOAP eg.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   preeti_b
Posted On:   Tuesday, May 7, 2002 09:18 AM

After deploying the service "Hi", I try to run the client "HiClient". The following error comes, Exception occoured : A 'http://schemas.xmlsoap.org/soap/envelope/:Fault' element must contain a: 'faultcode' element. returned from the service The dd and code are as follows ----------Deployment Desc---------- id="urn:HiService"> scope="Application" methods="sayHi"> org.apache.soap.server.DOMFaultListener xmlns:x="urn:HiService" qname="x:HiBean" javaType="samples.Hi.HiBean"    More>>

After deploying the service "Hi", I try to run the client "HiClient". The following error comes,



Exception occoured : A 'http://schemas.xmlsoap.org/soap/envelope/:Fault' element must contain a: 'faultcode' element.
returned from the service






The dd and code are as follows


----------Deployment Desc----------


id="urn:HiService">


scope="Application"
methods="sayHi">






org.apache.soap.server.DOMFaultListener





xmlns:x="urn:HiService" qname="x:HiBean"
javaType="samples.Hi.HiBean"

java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"

xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>






-----------------Service Hi.java -------


package samples.Hi;


public class Hi implements java.io.Serializable {

private String name = "";


public void Hi(){

this.name = "unKnown";

}


public void Hi(String name){

this.name = name;

}



public HiBean sayHi(String name) throws
IllegalArgumentException{
if(name == null || name =="")
throw new IllegalArgumentException("name must not be null or empty.");

return new HiBean(name);;

}


}


-----------------------Bean Class HiBean.java----------



package samples.Hi;

public class HiBean{

private String name;



public HiBean(){};



public HiBean(String name){

this.name = name;

}



public String toString(){

return "Hi, "+name+"!";

}

}



---------------------Client HiClient.java ---------


package samples.Hi;


import org.apache.soap.*;




public class HiClient{

public static void main(String [] args) throws
Exception{

String name = "";

if(args.length <1)

System.out.println("Usage : HiClient name");

else

name = args[0];

System.out.println("
name = "+name);

org.apache.soap.encoding.soapenc.BeanSerializer beanSer = new org.apache.soap.encoding.soapenc.BeanSerializer();


org.apache.soap.encoding.SOAPMappingRegistry soapMapReg = new org.apache.soap.encoding.SOAPMappingRegistry();

soapMapReg.mapTypes(org.apache.soap.Constants.NS_URI_SOAP_ENC, new org.apache.soap.util.xml.QName("urn:HiService","HiBean"), samples.Hi.HiBean.class, beanSer, beanSer) ;


org.apache.soap.rpc.Call call = new org.apache.soap.rpc.Call();

call.setSOAPMappingRegistry(soapMapReg);

call.setTargetObjectURI("urn:HiService");

call.setMethodName("sayHi");

call.setEncodingStyleURI(org.apache.soap.Constants.NS_URI_SOAP_ENC);
System.out.println("encoding = "+org.apache.soap.Constants.NS_URI_SOAP_ENC);


// preparing parameter for RPC

java.util.Vector params = new java.util.Vector();


//Parameter(java.lang.String name, java.lang.Class type, java.lang.Object value, java.lang.String encodingStyleURI)

params.add(new org.apache.soap.rpc.Parameter("nameToLookup", String.class, name, null));

call.setParams(params);

org.apache.soap.rpc.Response response = null;

try{

response = call.invoke(new java.net.URL ("http://localhost:8080/servlet/rpcrouter"),"");
}catch(org.apache.soap.SOAPException sx){
System.out.println("SOAP Exception occoured : "+sx.getMessage());

}

if(response == null)

System.out.println("Null returned from the service");

else if(response.generatedFault())

System.out.println("Fault returned from the service");
else{

org.apache.soap.rpc.Parameter retValue = response.getReturnValue();

Object obj = retValue.getValue();

System.out.println("Here is the response from the service


"+obj.toString()+"
****
");

}

}

}

-------------------------------



Thanks in advance for the help.

preeti..

   <<Less
About | Sitemap | Contact