users@jax-rpc.java.net

RemoteException/Runtime exception in deserialize

From: Suresh Y <suresh.yellamaraju_at_sun.com>
Date: Thu, 13 Feb 2003 02:38:16 -0700

Hi

I ran the program below and I get the following output/error. The Java code tries to get the exchange rate between the currencies of two countries. Interestingly I see the result of the call in the exception trace. I have run the code by passing the http.proxyHost and http.proxyPort as VM invocation parameters.

Is there something missing in the code I have written?

Thanks
Suresh


Exception trace:

Service name {http://www.xmethods.net/sd/CurrencyExchangeService.wsdl}CurrencyExchangeService
java.rmi.RemoteException: Runtime exception; nested exception is:
 deserialization error: XML reader error: unexpected character content: "120.85"
 at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:234)
 at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:54)
 at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:279)

Caused by: deserialization error: XML reader error: unexpected character content: "120.85"
 at com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBase.java:202)
 at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(ReferenceableSerializerImpl.java:115)
 at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvokerImpl.java:147)
 at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:170)
 ... 4 more
Process terminated with exit code 0



The Java code.

import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import java.util.Iterator;
import java.net.URL;

public class CurrenyExchangeTest {

    public static void main(String args[]) {
         new CurrenyExchangeTest().doTest();
    }

    void doTest() {
        try{
            javax.xml.rpc.ServiceFactory factory = javax.xml.rpc.ServiceFactory.newInstance();

            URL url = new URL("http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl");

            javax.xml.namespace.QName serviceQName =
                  new javax.xml.namespace.QName("http://www.xmethods.net/sd/CurrencyExchangeService.wsdl",
                          "CurrencyExchangeService");

            System.out.println("Service name " + serviceQName.toString());

            javax.xml.rpc.Service service = factory.createService(url, serviceQName);

            Call call = service.createCall();

            call.setOperationName(new QName("urn:xmethods-CurrencyExchange", "getRate"));

            call.setTargetEndpointAddress("http://services.xmethods.net:80/soap");

            call.setProperty(javax.xml.rpc.Call.OPERATION_STYLE_PROPERTY,
                    "rpc");
            call.setProperty(javax.xml.rpc.Call.SOAPACTION_USE_PROPERTY,
                    new Boolean(true));
            call.setProperty(javax.xml.rpc.Call.SOAPACTION_URI_PROPERTY,
                    "");
            call.setProperty("javax.xml.rpc.encodingstyle.namespace.uri",
                    "http://schemas.xmlsoap.org/soap/encoding/");

            Object returnValue = call.invoke(new String[]{"usa", "japan"});

            System.out.println(returnValue.toString());

        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
    }

}