getting the REmoteExceptionjava.rmi.MarshalException

Hi

I am unable to get the results while accessing the web service,

it is giving the error

REmoteExceptionjava.rmi.MarshalException: (1)Missing end tag for Body or Envelope

the error is occuring at

try {

resultObj = op.invoke(name);

} catch (JAXRPCException e) {

System.out.println("Error Here at Invoke");

Throwable cause = e.getLinkedCause();

if (cause instanceof java.rmi.RemoteException) {

throw (java.rmi.RemoteException) cause;

}

any body plz give sol for this problem

[560 byte] By [k_Arunreddia] at [2007-10-2 9:12:04]
# 1

I'm having the exact same problem.

I've used the wireless toolkit to generate the stubs for my project which is a simple helloworld app that takes two strings and returns a simple ok response.

I've also verified the webservice with an j2se client, and a wsdl verifier. No problems there. Also the server responds to the call, so it's got to be the MIDP client.

Anyone know what might be causing this?

As far as I know the main cause for a MarshalException is that either the client or server has different ideas of what the object is supposed to be?

Duffcasea at 2007-7-16 23:19:08 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

oh, and here's some code and errors if that might help:

This is the complete exception:

Running with storage root DefaultColorPhone

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)

Execution completed.

This is the stubs for the service:

// 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[i].equals(name)) {

_propertyValues[i] = 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[i].equals(name)) {

return _propertyValues[i];

}

}

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[i], _propertyValues[i].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!

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);

}

}

And this is the 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 {

}

}

Duffcasea at 2007-7-16 23:19:08 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

I've monitored the traffic on the wire, here are the xml going back and forth:

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>.

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>

Seems allright to me?

Duffcasea at 2007-7-16 23:19:08 > top of Java-index,Java Mobility Forums,Java ME Technologies...