Axis message-style ws and J2ME


XML & Web services: Axis message-style ws and J2ME

  1. Axis message-style ws and J2ME (1 messages)

    I'm trying to implement two clients for an Axis message service. One is for a j2se client and the other is j2me client. However I cannot use the same service for both of the clients. I will tell my problem using basic codes.

    J2ME Axis message-style web service code:

    1 public synchronized Element[] echoElements(Element[] params)
    2 {
    3 NodeList nodeList = params[0].getChildNodes();
    5 String elem0 = nodeList.item(1).getTextContent();
    6 String elem1 = nodeList.item(3).getTextContent();
    8 SOAPBodyElement[] message = new SOAPBodyElement[1];
    9 message[0] = new SOAPBodyElement(XMLUtils.StringToElement("", "message", ""));
    11 message[0].appendChild(new SOAPBodyElement(XMLUtils.StringToElement("urn:foo", "e0", "1:"+elem0)));
    12 message[0].appendChild(new SOAPBodyElement(XMLUtils.StringToElement("urn:foo", "e1", "2:"+elem1)));
    14 SOAPBodyElement[] result = new SOAPBodyElement[1];
    15 result[0] = new SOAPBodyElement(XMLUtils.StringToElement("", "result", ""));
    17 result[0].appendChild(message[0]);
    19 return result;
    20 }

    As you can see at lines 5 and 6 I can only take parameters giving indeces 1 and 3 for a mobile client.

    A part of theJ2ME client code:

    try {
        SoapObject client = new SoapObject("urn:foo","echoElements");
        HttpTransport ht = new HttpTransport("http://localhost:8080/axis/services/MessageService","urn:foo");
        SoapObject so = (SoapObject);
        System.out.println("arg0: "+so.getProperty(0));
        System.out.println("arg1: "+so.getProperty(1));
    } catch(Exception ex) {

    J2SE Axis message-style web service code:

    5 String elem0 = nodeList.item(0).getTextContent();
    6 String elem1 = nodeList.item(1).getTextContent();

    The same code except the lines 5 and 6. I can only take parameters giving indeces 0 and 1 for a console client.

    I don't understand why I have to change the indeces (1,3 for mobile - 0,1 for console)

    The Soap message is:

    <soapenv:Envelope xmlns:soapenv="" xmlns:xsd=" " xmlns:xsi="">
        <message xmlns="">
          <e1 xmlns="urn:foo">1:elem1</e1>
          <e2 xmlns="urn:foo">2:elem2</e2>

    Please can you tell me why?
  2. Axis message-style ws and J2ME[ Go to top ]

    Much more readable form is