Hi folks, I wrote a client code for accessing a simple web service. But SOAP 
request generated by axis2-saaj-1.1.1.jar seems to be having problem. 
I'm not able to add a text node to the ws operation element. I'm puzzled, am i 
doing something wrong or API is not working properly? pls suggest.


package com.ssk.ws.custom.wsdl.types;

import java.net.URL;

import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPMessage;

public class HRServiceClient {

        public static void main(String[] args) throws Exception {

                SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
                SOAPConnection sConn = scf.createConnection();
                
                MessageFactory mf = MessageFactory.newInstance();

                SOAPMessage msg = mf.createMessage();
                SOAPBody body = msg.getSOAPBody();
                
                SOAPFactory soapFactory = SOAPFactory.newInstance();
                
                Name bn = soapFactory.createName("getEmployee", 
                "ns1", "http://types.wsdl.custom.ws.ssk.com/xsd";);
                
                SOAPElement op = soapFactory.createElement(bn);
                
                body.addChildElement(op);

                Name pn = soapFactory.createName("p1", 
                                "ns1", 
"http://types.wsdl.custom.ws.ssk.com/xsd";);
                                
                SOAPElement p1 = soapFactory.createElement(pn);
                
                //1.doesnt work
                //p1.addTextNode("1");

                //2.doesnt work
                //SOAPElement val = p1.addTextNode("1");
                //p1.addChildElement(val);
                
                //3.doesnt work
                //p1.setValue("1");
                
                //4.doesnt work
                p1.setNodeValue("1");
                
                op.addChildElement(p1);
                
                java.net.URL endpoint = new URL(
                  "http://localhost:8080/axis2/services/HRService";);

                msg.writeTo(System.out);
                
                System.out.println();
                System.out.println();

                SOAPMessage response = sConn.call(msg, endpoint); 
                
                response.writeTo(System.out);
                
        }
}




<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
        <soapenv:Header />
        <soapenv:Body xmlns:ns1="http://types.wsdl.custom.ws.ssk.com/xsd";>
                <ns1:getEmployee 
xmlns="http://types.wsdl.custom.ws.ssk.com/xsd"; />
        </soapenv:Body>
</soapenv:Envelope>



Regards,
sigirisetti

This message and any attachment are confidential and may be privileged
or otherwise protected from disclosure. If you are not the intended
recipient please telephone or e-mail the sender and delete this message
and all attachments from your system. If you are not the intended
recipient you must not copy this message or any attachment or disclose
the contents to any other person.

Use of E-mails can involve substantial risks, including but not limited
to lack of confidentiality and potential manipulation of contents and/or
sender's address. E-mail transmission therefore cannot be guaranteed to
be secure, error-free or virus-free. UBS therefore does not accept
liability for any errors, omissions or consequences which arise as a
result of e-mail transmission. If you choose to send sensitive
information via e-mail, this will be done at your own risk.

This message is provided for informational purposes and is not intended
to nor will it create any binding legal relations. If verification is
required please request a hard-copy version.

This message should not be construed as a solicitation or offer to buy
or sell any securities or related financial instruments.

UBS AG does not accept Instructions via e-mail unless specifically
authorised in writing and agreed to by UBS AG.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to