Hi,
I am very new to Axis 2 and after going through the documentation
, i wrote a add service to get used to axis2. I wrote the service
class and generated the wsdl from it using using the Java2WSDL tool ,
and client stubs using WSDL2Java tool. After I deployed the service, I
get an exception saying "java.lang.RuntimeException: Unexpected
subelement return" , which is generated in the Clint stub. What is the
cause of this exception ? am I implementing the client and the service
the correct way ? Thank you very much in advance ....
~ Krishan
---------------------------------------- Service Method
-------------------------------------------------------
public static OMElement add ( OMElement elem )
{
Iterator iter = elem.getChildElements();
OMElement root = (OMElement)iter.next();
Iterator iter2 = root.getChildElements();
String param1Str = ((OMElement)iter2.next()).getText();
String param2Str = ((OMElement)iter2.next()).getText();
int answer = Integer.parseInt(param1Str) + Integer.parseInt(param2Str);
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns1 = factory.createOMNamespace
("http://services.axis2.test/xsd","ns1");
OMElement responce = factory.createOMElement("addResponse",ns1);
OMElement result = factory.createOMElement("return",ns1);
result.setText(String.valueOf(answer));
responce.addChild(result);
return responce;
}
------------------------------------------ Client Code
-------------------------------------------------------
AddServiceStub service = new AddServiceStub(null,
"http://localhost:7077/axis2/services/AddService");
AddServiceStub.Add paramOne = new AddServiceStub.Add();
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns5 =
factory.createOMNamespace("http://somenamespace","ns5");
OMElement paramArray = factory.createOMElement("root",ns5);
OMElement arg0 = factory.createOMElement("argO",ns5);
arg0.setText("2");
OMElement arg1 = factory.createOMElement("arg1",ns5);
arg1.setText("3");
paramArray.addChild(arg0);
paramArray.addChild(arg1);
paramOne.setElem(paramArray);
AddServiceStub.AddResponse responce = service.add(paramOne);
OMElement returnValue = responce.get_return();
System.out.println(returnValue.getText());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]