True there's a typo error in the entry above, now since i'm using the soap api directly, how do I post the http headers? the code I have looks as follows:
Code:
public SOAPMessage authenticateById(String urlStr, String id, String password) throws SOAPException, IOException {
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage sm = mf.createMessage();
SOAPHeader sh = sm.getSOAPHeader();
SOAPBody sb = sm.getSOAPBody();
/* Build soap header */
QName headerName = new QName("urn:zimbra", "context");
SOAPHeaderElement headerElement = sh.addHeaderElement(headerName);
QName noSessionQName = new QName("nosession");
headerElement.addChildElement(noSessionQName);
/* Build soap body */
QName serviceName = new QName("urn:zimbraAccount", "AuthRequest");
SOAPBodyElement bodyElement = sb.addBodyElement(serviceName);
QName nameQn = new QName("account");
SOAPElement nameElementValue = bodyElement.addChildElement(nameQn);
nameElementValue.addAttribute(new QName("by"), "name");
nameElementValue.addTextNode(id);
QName passwordQn = new QName("password");
SOAPElement passwordElementValue = bodyElement.addChildElement(passwordQn);
passwordElementValue.addTextNode(password);
sm.writeTo(System.out);
URL url = new URL(urlStr);
Service service = Service.create(url, serviceName);
Dispatch<SOAPMessage> dispatch = service.createDispatch(serviceName, SOAPMessage.class, Service.Mode.MESSAGE);
SOAPMessage request = MessageFactory.newInstance().createMessage(null, new FileInputStream("result.xml"));
SOAPMessage response = dispatch.invoke(request);
response.writeTo(System.out);
return sm;
} So basically to invoke the AuthRequest for user: henry with password 1234 at url https://localhost:7071/soap/admin/service you would do the following
Code:
authenticateById("https://localhost:7071/service/admin/soap", "henry", "1234");