1
我使用的是使用jax ws的Php soap服務器和java客戶端。 如何在隨後的請求中添加soap頭中的sessionId? 它的格式是什麼?使用saaj在肥皂標題中添加會話標識
到目前爲止,我這樣做:
String url = "http://localhost:8888/server/soap/server.php";
// login
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage request = mf.createMessage();
SOAPPart soapPart = request.getSOAPPart();
MimeHeaders headers = request.getMimeHeaders();
headers.addHeader("SOAPAction", url);
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("var", url);
SOAPBody soapBody = envelope.getBody();
SOAPElement soapBodyElem = soapBody.addChildElement("call", "var");
SOAPElement action = soapBodyElem.addChildElement("action", "var");
action.addTextNode("LOGON");
SOAPElement params = soapBodyElem.addChildElement("params", "var");
SOAPElement uid = soapBodyElem.addChildElement("uid ", "var");
uid .addTextNode("tester");
SOAPElement password = soapBodyElem.addChildElement("password ", "var");
password .addTextNode("");
params.addChildElement(uid);
params.addChildElement(password);
request.saveChanges();
/* Print the request message */
System.out.print("Request SOAP Message:");
request.writeTo(System.out);
System.out.println();
SOAPMessage response = soapConnection.call(request, url);
上述要求的作品,因爲它是在登錄階段,並即將獲得的會話ID。但接下來的請求呢?