Axis message-style ws and J2ME

Discussions

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();
    4
    5 String elem0 = nodeList.item(1).getTextContent();
    6 String elem1 = nodeList.item(3).getTextContent();
    7
    8 SOAPBodyElement[] message = new SOAPBodyElement[1];
    9 message[0] = new SOAPBodyElement(XMLUtils.StringToElement("", "message", ""));
    10
    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)));
    13
    14 SOAPBodyElement[] result = new SOAPBodyElement[1];
    15 result[0] = new SOAPBodyElement(XMLUtils.StringToElement("", "result", ""));
    16
    17 result[0].appendChild(message[0]);
    18
    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");
                           
        client.addProperty("e1","elem1");
        client.addProperty("e2","elem2");
                
        HttpTransport ht = new HttpTransport("http://localhost:8080/axis/services/MessageService","urn:foo");
                
        SoapObject so = (SoapObject)ht.call(client);
                
        System.out.println("arg0: "+so.getProperty(0));
        System.out.println("arg1: "+so.getProperty(1));
    } catch(Exception ex) {
        System.out.println("Exception:");
        ex.printStackTrace();
    }


    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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <message xmlns="">
          <e1 xmlns="urn:foo">1:elem1</e1>
          <e2 xmlns="urn:foo">2:elem2</e2>
        </message>
    </soapenv:Body>
    </soapenv:Envelope>


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

    Much more readable form is

    http://forum.java.sun.com/thread.jspa?threadID=617329&tstart=0