File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Deserialization Exception while using string[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Deserialization Exception while using string[]" Watch "Deserialization Exception while using string[]" New topic
Author

Deserialization Exception while using string[]

sudheshna Iyer
Ranch Hand

Joined: Aug 20, 2004
Posts: 71
I am using dynamic stubs to invoke web service that returns String[].

I am having the problem:

javax.xml.rpc.JAXRPCException: failed to invoke operation 'getXXX' due to an error in the soap layer (SAAJ); nested exception is: Message[failed to deserialize xml:weblogic.xml.schema.binding.DeserializationException: mapping lookup failure for xml type ['java:language_builtins.lang']:ArrayOfString and java interface javax.xml.soap.SOAPElement]StackTrace[


Here is the code:
System.setProperty("javax.xml.soap.MessageFactory",
"weblogic.webservice.core.soap.MessageFactoryImpl");
// Setup the global JAX-RPC service factory
System.setProperty( "javax.xml.rpc.ServiceFactory",
"weblogic.webservice.core.rpc.ServiceFactoryImpl");

// create service factory
ServiceFactory factory = ServiceFactory.newInstance();

// define qnames
String targetNamespace = "http://localhost:7001/SaWS";

QName serviceName =
new QName(targetNamespace,
"SarWSServiceName");

QName portName =
new QName(targetNamespace,
"SaWSServiceNamePort");

QName operationName = new QName(targetNamespace,
"getXXX");

URL wsdlLocation =
new URL("http://localhost:7001/SaWS/SaWSURI?wsdl");

// create service
Service service = factory.createService(wsdlLocation, serviceName);

Call call = service.createCall(portName, operationName);

TypeMappingRegistry registry = service.getTypeMappingRegistry();

TypeMapping typemapping = registry.getTypeMapping(SOAPConstants.URI_NS_SOAP_ENCODING);

typemapping.register(
java.lang.String[].class,
new QName("http://www.w3.org/2001/XMLSchema", "ArrayOfString"),
new language_builtins.lang.ArrayOfStringCodec(),
new language_builtins.lang.ArrayOfStringCodec()
);

String cust_number = "40230505";
Object[] res = (Object[]) call.invoke(new Object[]{cust_number} );
System.out.println( "res.length : " + res.length );
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Deserialization Exception while using string[]