java - Sending array of string as a parameter to web service method using JAXRPC -
i've got problem sending array of string parameter web service method, given in specific wsdl. when trying send array of strings, following error.
error:
axisfault faultcode: {http://schemas.xmlsoap.org/soap/envelope/}server.userexception faultsubcode: faultstring: org.xml.sax.saxexception: bad types (class java.util.arraylist > class usdjws65.arrayofstring) faultactor: faultnode: faultdetail: {http://xml.apache.org/axis/}hostname:sslspsd001 org.xml.sax.saxexception: bad types (class java.util.arraylist -> class usdjws65.arrayofstring) @ org.apache.axis.message.soapfaultbuilder.createfault(soapfaultbuilder.java:222) @ org.apache.axis.message.soapfaultbuilder.endelement(soapfaultbuilder.java:129) @ org.apache.axis.encoding.deserializationcontext.endelement(deserializationcontext.java:1087)
code written:
call call1 = objservice1.createcall(port1); call1.settargetendpointaddress(targetendpoint); call1.addparameter("int_1", xmltype.xsd_int, integer.class, parametermode.in); call1.addparameter("string_1", qname_type_string, parametermode.in); call1.addparameter("string_2", qname_type_string_array, java.lang.string[].class, parametermode.in); call1.addparameter("string_3", qname_type_string_array, java.lang.string[].class, parametermode.in); call1.addparameter("string_4", qname_type_string, parametermode.in); call1.addparameter("string_5", qname_type_string_array, java.lang.string[].class, parametermode.in); call1.addparameter("string_6", qname_type_string, parametermode.in); call1.addparameter("string_7", qname_type_string, parametermode.in); // --- done adding param's string[] attrvals = { "description", "test soapui", "customer", tickethandle, "type", "i" }; string[] attributes = { "status", "ref_num" }; object[] params1 = { new integer(sid), tickethandle, attrvals, "", "cr_tpl:400005", attributes, "", "" }; string res = null; try { call1.invoke(params1);
thanks !!!! -aj
=========================================================
update-1:
i added class named arrayofstring following code in it. protected java.lang.string[] string;
public arrayofstring() { } public arrayofstring(java.lang.string[] string) { this.string = string; } public java.lang.string[] getstring() { return string; } public void setstring(java.lang.string[] string) { this.string = string; }
and did following, arrayofstring attrvals = new arrayofstring(); attrvals.setstring(new string[] { "customer", "test soapui", "customer", tickethandle, "type", "i" });
similarly, attributes variable of type 'arrayofstring'.
but now, following error::
axisfault faultcode: {http://schemas.xmlsoap.org/soap/envelope/}server.userexception faultsubcode: faultstring: java.io.ioexception: no serializer found class arrayofstring in registry org.apache.axis.encoding.typemappingdelegate@ef2c60 faultactor: faultnode: faultdetail: {http://xml.apache.org/axis/}stacktrace:java.io.ioexception: no serializer found class arrayofstring in registry org.apache.axis.encoding.typemappingdelegate@ef2c60 @ org.apache.axis.encoding.serializationcontext.serializeactual(serializationcontext.java:1507) @ org.apache.axis.encoding.serializationcontext.serialize(serializationcontext.java:980) @ org.apache.axis.encoding.serializationcontext.outputmultirefs(serializationcontext.java:1055) @ org.apache.axis.message.soapbody.outputimpl(soapbody.java:145) @ org.apache.axis.message.soapenvelope.outputimpl(soapenvelope.java:478) @ org.apache.axis.message.messageelement.output(messageelement.java:1208) @ org.apache.axis.client.call.invoke(call.java:2757) @ org.apache.axis.client.call.invoke(call.java:2443) @ org.apache.axis.client.call.invoke(call.java:2366) @ org.apache.axis.client.call.invoke(call.java:1812)
update-2:
here update on problem facing. in wsdl file, found this,
complextype name="arrayofstring" sequence element maxoccurs="unbounded" name="string" type="xsd:string" / /sequence /complextype
well, meant use method,
<element name="createrequest"> <complextype> <sequence> <element name="sid" type="xsd:int" /> <element name="creatorhandle" type="xsd:string" /> <element name="attrvals" type="impl:arrayofstring" /> <element name="propertyvalues" type="impl:arrayofstring" /> <element name="template" type="xsd:string" /> <element name="attributes" type="impl:arrayofstring" /> <element name="newrequesthandle" type="xsd:string" /> <element name="newrequestnumber" type="xsd:string" /> </sequence> </complextype> </element>
now, tried sending parameters 'attrvals','attibutes' this
arrayofstring attrvals = new arrayofstring(); arrayofstring attributes = new arrayofstring(); attrvals.setstring(new string[] { "customer", "test soapui", "customer", tickethandle, "type", "i" }); attributes.setstring(new string[] { "status", "ref_num" });
its throwing following exception
axisfault faultcode: {http://schemas.xmlsoap.org/soap/envelope/}server.userexception faultsubcode: faultstring: java.io.ioexception: no serializer found class org.tempuri.complex.data.arrays.xsd.arrayofstring in registry org.apache.axis.encoding.typemappingdelegate@11e1e67 faultactor: faultnode: faultdetail: {http://xml.apache.org/axis/}stacktrace:java.io.ioexception: no serializer found class org.tempuri.complex.data.arrays.xsd.arrayofstring in registry org.apache.axis.encoding.typemappingdelegate@11e1e67 @ org.apache.axis.encoding.serializationcontext.serializeactual(serializationcontext.java:1507) @ org.apache.axis.encoding.serializationcontext.serialize(serializationcontext.java:980)
the above error has been solved. registered arrayofstring class, string[] typeregistrymapping class. now, doesn't throw above serialize error. code edited is:
servicefactory factory1 = servicefactory.newinstance(); qname qntick = new qname("http://soapinterop.org/xsd", "arrayofstring"); service servicetickreq = factory1.createservice(qntick); // service servicetickreq = new org.apache.axis.client.service(); typemappingregistry tmr = (typemappingregistry) servicetickreq .gettypemappingregistry(); typemapping tm = (typemapping) tmr.getdefaulttypemapping(); tm.register(arrayofstring.class, qntick, new beanserializerfactory( arrayofstring.class, qntick), new beandeserializerfactory( arrayofstring.class, qntick)); typemappingregistry tmr1 = (typemappingregistry) servicetickreq .gettypemappingregistry(); typemapping tm1 = (typemapping) tmr1.getdefaulttypemapping(); tm1.register(string[].class, qntick, new beanserializerfactory( string[].class, qntick), new beandeserializerfactory( string[].class, qntick));
Comments
Post a Comment