5 Replies Latest reply on Apr 18, 2005 8:38 AM by thomas.diesler

    Returning a complex type

    dannox02

      I have a web service deployed as rpc-literal. I have two methods, one returns an int, the other a complex type "Persion". What steps do I need to follow to get serialzation/deserialization of my complex type to work? I've found alot of examples of web services using simple types... none with complex types.

      Returning the int works fine in my client, but when I try to call getPerson(), I get an exception:

      java.rmi.RemoteException: Runtime exception; nested exception is:
       unexpected element name: expected=result, actual={urn:Foo}Person
       at com.sun.xml.rpc.client.StreamingSender._handleRuntimeExceptionInSend(StreamingSender.java:318)
       at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:300)
       at com.danny.CalculatorService_Stub.getPerson(CalculatorService_Stub.java:69)
       at com.danny.CalculatorClient.main(CalculatorClient.java:22)
      Caused by: unexpected element name: expected=result, actual={urn:Foo}Person
       at com.danny.CalculatorService_getPerson_ResponseStruct_LiteralSerializer.doDeserialize(CalculatorService_getPerson_ResponseStruct_LiteralSerializer.java:57)
       at com.sun.xml.rpc.encoding.literal.LiteralObjectSerializerBase.internalDeserialize(LiteralObjectSerializerBase.java:216)
       at com.sun.xml.rpc.encoding.literal.LiteralObjectSerializerBase.deserialize(LiteralObjectSerializerBase.java:124)
       at com.danny.CalculatorService_Stub._deserialize_getPerson(CalculatorService_Stub.java:174)
       at com.danny.CalculatorService_Stub._readFirstBodyElement(CalculatorService_Stub.java:157)
       at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:215)
       ... 2 more

      I use wscompile to create both the server and the client. The client using the command:
      wscompile -gen:client -f:rpcliteral -f:wsi -mapping jaxrpc-mapping.xml -d build -keep config.xml

      My config.xml looks like this:
      <?xml version="1.0" encoding="UTF-8"?>
      <configuration
       xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
       <wsdl location="http://xxx:8080/CalculatorService/CalculatorService?wsdl"
       packageName="com.danny"/>
      </configuration>