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 Pa...@Expeditors.com on 2004/02/19 23:50:53 UTC

Retrieve objects from SOAP response

Hi,
I have a SOAP service that returns objects. I know the method works, cos' 
I can see the output in TCPMON, However when I try to retrieve them I get 
a StringIndexOutOfBoundException

This is my code for creating and sending the request. 
I have registered all the appropriate Serializers and Deserializers for 
the object that I am sending and hope to receive


call.setOperation("executeRequest"); 
call.setOperationName(new QName("urn:ExpoServiceInterface", "executeRequest")); 

Class beanSF = BeanSerializerFactory.class;
Class beanDF = BeanDeserializerFactory.class; 
QName qName = new javax.xml.namespace.QName("OC315SearchRequest", "OC315SearchRequest"); 
call.registerTypeMapping(OC315SearchRequest.class, qName, beanSF, beanDF);
qName = new javax.xml.namespace.QName("EIResponse", "EIResponse");
call.registerTypeMapping(EIResponse.class, qName, beanSF, beanDF);

call.addParameter( "outMsg", XMLType.XSD_ANYTYPE, ParameterMode.IN );
call.setReturnType(new QName("EIResponse", "EIResponse"), EIResponse.class); 
EIResponse obj = (EIResponse) call.invoke(new Object[] {request});


When I run this method I get this exception, Can anyone tell me how to 
retrieve objects from a SOAP response.

AxisFault
 faultCode: 
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.lang.StringIndexOutOfBoundsException: String index out 
of range: 0
 faultActor: 
 faultNode: 
 faultDetail: 
        {http://xml.apache.org/axis/}stackTrace: 
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at 
org.apache.axis.encoding.ser.SimpleDeserializer.onEndElement(SimpleDeserializer.java:226)
        at 
org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:534)
        at 
org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
        at 
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:204)
        at 
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)
        at 
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
        at 
org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
        at org.apache.axis.client.Call.invoke(Call.java:2272)
        at org.apache.axis.client.Call.invoke(Call.java:2171)
        at org.apache.axis.client.Call.invoke(Call.java:1691)
        at SoapRequestImpl.runExecuteRequest(SoapRequestImpl.java:96)
        at SoapRequestImpl.main(SoapRequestImpl.java:60)
 

Thanks,
Parul


Re: Retrieve objects from SOAP response

Posted by Tony Blair <hr...@yahoo.com>.
Hi there,
 
One thing that I noticed is your :
call.addParameter( "outMsg", XMLType.XSD_ANYTYPE, ParameterMode.IN ); you need pass the qName as oppose to XMLType.XSD_ANTYPE.
 
Try this.
 
Regards,
Tony.

Parul.Joshi@Expeditors.com wrote:

Hi, 
I have a SOAP service that returns objects. I know the method works, cos' I can see the output in TCPMON, However when I try to retrieve them I get a StringIndexOutOfBoundException 

This is my code for creating and sending the request. 
I have registered all the appropriate Serializers and Deserializers for the object that I am sending and hope to receive 


call.setOperation("executeRequest");       
call.setOperationName(new QName("urn:ExpoServiceInterface", "executeRequest"));                 

Class beanSF = BeanSerializerFactory.class; 
Class beanDF = BeanDeserializerFactory.class;                   
QName qName = new javax.xml.namespace.QName("OC315SearchRequest", "OC315SearchRequest");                 
call.registerTypeMapping(OC315SearchRequest.class, qName, beanSF, beanDF); 
qName = new javax.xml.namespace.QName("EIResponse", "EIResponse"); 
call.registerTypeMapping(EIResponse.class, qName, beanSF, beanDF); 

call.addParameter( "outMsg", XMLType.XSD_ANYTYPE, ParameterMode.IN ); 
call.setReturnType(new QName("EIResponse", "EIResponse"), EIResponse.class);                         
EIResponse obj = (EIResponse) call.invoke(new Object[] {request}); 


When I run this method I get this exception, Can anyone tell me how to retrieve objects from a SOAP response. 

AxisFault 
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException 
 faultSubcode: 
 faultString: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 
 faultActor: 
 faultNode: 
 faultDetail: 
        {http://xml.apache.org/axis/}stackTrace: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 
        at org.apache.axis.encoding.ser.SimpleDeserializer.onEndElement(SimpleDeserializer.java:226) 
        at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:534) 
        at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015) 
        at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:204) 
        at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722) 
        at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233) 
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347) 
        at org.apache.axis.client.Call.invoke(Call.java:2272) 
        at org.apache.axis.client.Call.invoke(Call.java:2171) 
        at org.apache.axis.client.Call.invoke(Call.java:1691) 
        at SoapRequestImpl.runExecuteRequest(SoapRequestImpl.java:96) 
        at SoapRequestImpl.main(SoapRequestImpl.java:60) 
                

Thanks,
Parul 



---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.