AnsweredAssumed Answered

SOAP Connection - Java - Null Result

Question asked by darrengreer on Dec 13, 2011
Latest reply on Jan 31, 2013 by snaptest
All,

I'm attempting to connect to the clarity web services, and authenticate, but my soap results are always coming back null. Here is the test code:
public class SOAPTest {


public static void main (String args[]) {


try {


      SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();


      SOAPConnection connection = sfc.createConnection();


      MessageFactory mf = MessageFactory.newInstance();


      SOAPMessage sm = mf.createMessage();


      SOAPPart soapPart = sm.getSOAPPart();


      


      SOAPBody sb = sm.getSOAPBody();


        


      QName bodyName = new QName("http://www.niku.com/xog", "Login");


      SOAPBodyElement bodyElement = sb.addBodyElement(bodyName);



      QName userName = new QName("http://www.niku.com/xog", "Username");


      SOAPElement userNameElement = bodyElement.addChildElement(userName);


      userNameElement.addTextNode("admin");



      QName userPass = new QName("http://www.niku.com/xog", "Password");


      SOAPElement passwordElement = bodyElement.addChildElement(userPass);


      passwordElement.addTextNode("admin");


      


      sm.writeTo(System.out);


      System.out.println();



      URL endpoint = new URL("http://localhost/niku/xog");


      SOAPMessage response = connection.call(sm, endpoint);


      SOAPPart sp = response.getSOAPPart();


      SOAPEnvelope ev = sp.getEnvelope();


      SOAPBody bd = ev.getBody();


      String result = bd.getValue();


      System.out.println(result);


      System.out.println(response.getContentDescription());






      System.out.println("done");


} catch (Exception e) {



e.printStackTrace();


}

}


}
It connects fine, and no errors are thrown, but when trying to print the results, the envelope is null. If successful, it should be returning the sessionID correct?

Any pointers would be greatly appreciated.

Outcomes