Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Finally solved my issue (Ive changed Element names etc.), using eclipse shows you the Soap envelope and XML response which i found useful for debugging the envelope). Hope this helps anyone trying to do similar.</p> <p>The "UploadMessage" is the "Login" string and the </p> <pre><code>$param_auth=array( 'user'=&gt;$username, 'id'=&gt;$userID, 'message'=&gt;$userMessage ); </code></pre> <p>is the Username and Password, (Left out the Message part).</p> <p>This code sends an Envelope like this the server:-</p> <pre><code> &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:Login="Your URL"&gt;&lt;SOAP-ENV:Header/&gt;&lt;SOAP-ENV:Body&gt;&lt;Login&gt;&lt;UserName&gt;YourUserName&lt;/UserName&gt;&lt;Password&gt;YourPassword&lt;/Password&gt;&lt;/Login&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>Code To create the above Envelope is below:-</p> <pre><code>import javax.xml.soap.*; import javax.xml.transform.*; import javax.xml.transform.stream.*; public class SoapCall { public static void main(String args[]) { try { // Create SOAP Connection SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); // Send SOAP Message to SOAP Server. String url = "Your URL"; SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url); // Process the SOAP Response printSOAPResponse(soapResponse); soapConnection.close(); } catch (Exception e) { System.err.println("Error occurred while sending SOAP Request to Server"); e.printStackTrace(); } } private static SOAPMessage createSOAPRequest() throws Exception { String YourUsername = "UserName"; String YourPassword = "Password"; MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "Your URL"; // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("Login", serverURI); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement("Login"); SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("UserName"); soapBodyElem2.addTextNode(YourUserName); SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("Password"); soapBodyElem3.addTextNode(YourPassword); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "Login"); soapMessage.saveChanges(); /* Print the request message */ System.out.print("Request SOAP Message = "); soapMessage.writeTo(System.out); System.out.println(); return soapMessage; } /** * Method used to print the SOAP Response */ private static void printSOAPResponse(SOAPMessage soapResponse) throws Exception { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); Source sourceContent = soapResponse.getSOAPPart().getContent(); System.out.print("\nResponse SOAP Message = "); StreamResult result = new StreamResult(System.out); transformer.transform(sourceContent, result); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload