Getting rmi.MarshalException from my client.
duffcase May 22, 2006 6:19 AMHi.
I'm trying to make a simple implementation of a webservice using document/literal and J2Me CLDC1.1 MIDP2.0
I've been using a combination of jbossws and suns wireless toolkit, but the errors are the same.
I used wstools to generate all the essential stuff.
The problem is I'm getting this exceptionn when running it on a device emulator included with the wtk:
java.rmi.MarshalException: (1)Missing end tag for Body or Envelope at com.stubs.TrivialService_Stub.purchase(+75) at com.apps.TestClient.startApp(+47) at javax.microedition.midlet.MIDletProxy.startApp(+7) at com.sun.midp.midlet.Scheduler.schedule(+270) at com.sun.midp.main.Main.runLocalClass(+28) at com.sun.midp.main.Main.main(+116)
I've verified the web service with a j2se client, runs smoothly without any hickups.
This is my simple MIDlet client:
package com.apps;
import java.rmi.RemoteException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.xml.rpc.Stub;
import com.stubs.TrivialService;
import com.stubs.TrivialService_Stub;
public class TestClient extends MIDlet {
protected void startApp() throws MIDletStateChangeException {
Form form = new Form("First test");
form.append("HEllo Oinkers!");
Display.getDisplay(this).setCurrent(form);
TrivialService_Stub stub = new TrivialService_Stub();
TrivialService ts = (TrivialService)stub;
stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://10.0.102.112:8080/warme?wsdl");
try {
ts.purchase("Person","product");
} catch (RemoteException e) {
e.printStackTrace();
}
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
}
and this is the stubs:
// This class was generated by 172 StubGenerator.
// Contents subject to change without notice.
// @generated
package com.stubs;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.microedition.xml.rpc.Operation;
import javax.microedition.xml.rpc.Type;
import javax.microedition.xml.rpc.ComplexType;
import javax.microedition.xml.rpc.Element;
public class TrivialService_Stub implements com.stubs.TrivialService, javax.xml.rpc.Stub {
private String[] _propertyNames;
private Object[] _propertyValues;
public TrivialService_Stub() {
_propertyNames = new String[] {ENDPOINT_ADDRESS_PROPERTY};
_propertyValues = new Object[] {"http://10.0.102.112:8080/warme"};
}
public void _setProperty(String name, Object value) {
int size = _propertyNames.length;
for (int i = 0; i < size; ++i) {
if (_propertyNames.equals(name)) {
_propertyValues = value;
return;
}
}
// Need to expand our array for a new property
String[] newPropNames = new String[size + 1];
System.arraycopy(_propertyNames, 0, newPropNames, 0, size);
_propertyNames = newPropNames;
Object[] newPropValues = new Object[size + 1];
System.arraycopy(_propertyValues, 0, newPropValues, 0, size);
_propertyValues = newPropValues;
_propertyNames[size] = name;
_propertyValues[size] = value;
}
public Object _getProperty(String name) {
for (int i = 0; i < _propertyNames.length; ++i) {
if (_propertyNames.equals(name)) {
return _propertyValues;
}
}
if (ENDPOINT_ADDRESS_PROPERTY.equals(name) || USERNAME_PROPERTY.equals(name) || PASSWORD_PROPERTY.equals(name)) {
return null;
}
if (SESSION_MAINTAIN_PROPERTY.equals(name)) {
return new java.lang.Boolean(false);
}
throw new JAXRPCException("Stub does not recognize property: "+name);
}
protected void _prepOperation(Operation op) {
for (int i = 0; i < _propertyNames.length; ++i) {
op.setProperty(_propertyNames, _propertyValues.toString());
}
}
//
// Begin user methods
//
public java.lang.String purchase(java.lang.String string_1, java.lang.String string_2) throws java.rmi.RemoteException {
// Copy the incoming values into an Object array if needed.
Object[] inputObject = new Object[2];
inputObject[0] = string_1;
inputObject[1] = string_2;
Operation op = Operation.newInstance(_qname_wrapped_purchase, _type_purchase, _type_purchaseResponse);
_prepOperation(op);
op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "");
Object resultObj;
try {
resultObj = op.invoke(inputObject);
} catch (JAXRPCException e) {
Throwable cause = e.getLinkedCause();
if (cause instanceof java.rmi.RemoteException) {
System.out.println("this is where it's at!"); // this is the feil!
System.out.println(_type_purchaseResponse.toString());
throw (java.rmi.RemoteException) cause;
}
throw e;
}
java.lang.String result;
// Convert the result into the right Java type.
// Unwrapped return value
Object resultObj2 = ((Object[])resultObj)[0];
result = (java.lang.String)resultObj2;
return result;
}
//
// End user methods
//
protected static final QName _qname_String_1 = new QName("", "String_1");
protected static final QName _qname_String_2 = new QName("", "String_2");
protected static final QName _qname_result = new QName("", "result");
protected static final QName _qname_wrapped_purchase = new QName("http://org.jboss.ws/samples/docstyle/wrapped", "purchase");
protected static final QName _qname_purchase = new QName("http://org.jboss.ws/samples/docstyle/wrapped/types", "purchase");
protected static final QName _qname_purchaseResponse = new QName("http://org.jboss.ws/samples/docstyle/wrapped/types", "purchaseResponse");
protected static final Element _type_purchase;
protected static final Element _type_purchaseResponse;
static {
// Create all of the Type's that this stub uses, once.
Element _type_String_1;
_type_String_1 = new Element(_qname_String_1, Type.STRING, 1, 1, true);
Element _type_String_2;
_type_String_2 = new Element(_qname_String_2, Type.STRING, 1, 1, true);
ComplexType _complexType_purchase;
_complexType_purchase = new ComplexType();
_complexType_purchase.elements = new Element[2];
_complexType_purchase.elements[0] = _type_String_1;
_complexType_purchase.elements[1] = _type_String_2;
_type_purchase = new Element(_qname_purchase, _complexType_purchase);
Element _type_result;
_type_result = new Element(_qname_result, Type.STRING, 1, 1, true);
ComplexType _complexType_purchaseResponse;
_complexType_purchaseResponse = new ComplexType();
_complexType_purchaseResponse.elements = new Element[1];
_complexType_purchaseResponse.elements[0] = _type_result;
_type_purchaseResponse = new Element(_qname_purchaseResponse, _complexType_purchaseResponse);
}
}
I've also used a network monitor to intercept the data beeing sent over the wire:
the request:
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://org.jboss.ws/samples/docstyle/wrapped/types"> <soap:Body> <tns:purchase> <String_1 xmlns="">person</String_1> <String_2 xmlns="">product</String_2> </tns:purchase> </soap:Body> </soap:Envelope>
and the response:
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'> <env:Header/> <env:Body> <ns1:purchaseResponse xmlns:ns1='http://org.jboss.ws/samples/docstyle/wrapped/types' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> <result>okPersonProduct</result> </ns1:purchaseResponse> </env:Body> </env:Envelope>
hopefully someone can see whats wrong here..