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 webservice guy <ws...@rediffmail.com> on 2006/01/21 11:11:04 UTC
DII clinet problem for complex types ( java bean)
Dear ALL
I am new bie to web service and facing problem in Client program (DII type, java bean) using axis with tomcat on windows.
I need help urgently please try to help me.. Am I missing something any working example with axis will be very helpful.
Tons of thanks in advance..
Kind regards
wsguy
Following are the code
WSDL :
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost:8080/axis/HelloService2.jws" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/axis/HelloService2.jws" xmlns:intf="http://localhost:8080/axis/HelloService2.jws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://DefaultNamespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT)-->
<wsdl:types>
<schema targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://localhost:8080/axis/HelloService2.jws"/>
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="HelloBean">
<sequence>
<element name="name" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
<schema targetNamespace="http://localhost:8080/axis/HelloService2.jws" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://DefaultNamespace"/>
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOf_tns1_HelloBean">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:HelloBean[]"/>
</restriction>
</complexContent>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="helloBeanResponse">
<wsdl:part name="helloBeanReturn" type="tns1:HelloBean"/>
</wsdl:message>
<wsdl:message name="helloBeanArrayResponse">
<wsdl:part name="helloBeanArrayReturn" type="impl:ArrayOf_tns1_HelloBean"/>
</wsdl:message>
<wsdl:message name="helloBeanRequest">
<wsdl:part name="name" type="tns1:HelloBean"/>
</wsdl:message>
<wsdl:message name="helloBeanArrayRequest">
<wsdl:part name="names" type="impl:ArrayOf_tns1_HelloBean"/>
</wsdl:message>
<wsdl:portType name="HelloService2">
<wsdl:operation name="helloBean" parameterOrder="name">
<wsdl:input message="impl:helloBeanRequest" name="helloBeanRequest"/>
<wsdl:output message="impl:helloBeanResponse" name="helloBeanResponse"/>
</wsdl:operation>
<wsdl:operation name="helloBeanArray" parameterOrder="names">
<wsdl:input message="impl:helloBeanArrayRequest" name="helloBeanArrayRequest"/>
<wsdl:output message="impl:helloBeanArrayResponse" name="helloBeanArrayResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloService2SoapBinding" type="impl:HelloService2">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="helloBean">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="helloBeanRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="helloBeanResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/HelloService2.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="helloBeanArray">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="helloBeanArrayRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="helloBeanArrayResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/HelloService2.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloService2Service">
<wsdl:port binding="impl:HelloService2SoapBinding" name="HelloService2">
<wsdlsoap:address location="http://localhost:8080/axis/HelloService2.jws"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Hello Bean:
/** A simple bean for testing */
public class HelloBean {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
Hello Service
/** Simple test of HelloBean and HelloBean[] parameters and return values */
public class HelloService2 {
/** Says hello to one person */
public HelloBean helloBean(HelloBean name) {
HelloBean ret = new HelloBean();
ret.setName(" CONCATING HELLO , " + name.getName());
return ret;
}
/** Says hello to many people */
public HelloBean[] helloBeanArray(HelloBean[] names) {
HelloBean[] ret = new HelloBean[names.length];
for (int i = 0; i < names.length; i++) {
ret[i] = new HelloBean();
ret[i].setName("Hello Mr. --> " + names[i].getName());
}
return ret;
}
}
Client
public static void main(String[] args) throws Exception {
/*
if (args.length < 2) {
System.err.println("Usage: java HelloClient2 SOAP-router-URL name [name ...]");
System.exit(1);
}
*/
HelloBean hb = new HelloBean( );
i1.setName("TestName");
Service service = new Service();
Call call= (Call) service.createCall();
System.out.println("call");
QName qName = new QName("http://www.w3.org/2001/XMLSchema", "HelloBean");
System.out.println("qName1");
call.registerTypeMapping(HelloBean.class,qName, new BeanSerializerFactory(HelloBean.class,qName), new BeanDeserializerFactory(HelloBean.class,qName));
System.out.println("qName2");
call.setTargetEndpointAddress( new java.net.URL("http://localhost:8080/axis/HelloService2.jws") );
System.out.println("qName3");
call.setOperationName( "helloBean" );
System.out.println("qName4");
call.addParameter( qName, XMLType.XSD_ANYTYPE, ParameterMode.IN);
System.out.println("setReturnType");
call.setReturnType( org.apache.axis.encoding.XMLType.XSD_ANYTYPE );
HelloBean ret = (HelloBean) call.invoke( new Object [] {hb});
System.out.println("ret5");
System.out.println("Got result working : " + ret.getName());
}
Exception :
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode:
faultString: org.xml.sax.SAXException: Deserializing parameter 'HelloBean': could not find deserializer for type {http:// http://www.w3.org/2001/XMLSchema}HelloBean
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:machine name