This discussion is archived
1 Reply Latest reply: Jun 25, 2012 7:02 AM by jtahlborn RSS

SOAP request to webservice

944929 Newbie
Currently Being Moderated
I'm trying to create some integration with a partner but I'm not a soap expert. (although I've started to read up on it) I'm supposed to make a soap request to their web service, which which will do some kind of authentication on their end, then return a url to me if successful. They gave me the following sample XML:
<soapenv:Envelope xmlns:olsa="http://www.company.com/services/olsa_v1_0/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsu:Timestamp wsu:Id="Timestamp-15" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsu:Created>2012-06-19T03:28:20.990Z</wsu:Created>
            <wsu:Expires>2012-06-19T03:29:20.990Z</wsu:Expires>
         </wsu:Timestamp>
         <wsse:UsernameToken wsu:Id="UsernameToken-14" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>customerID</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">hDLu/mTTJXFtCsxjeufx097Hry4=</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">SIM5WxaZFKdAK/gHXvNUww==</wsse:Nonce>
            <wsu:Created>2012-06-19T03:28:17.231Z</wsu:Created>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <olsa:GetMultiActionSignOnUrlRequest>
         <olsa:customerId>customerID</olsa:customerId>
         <olsa:userName>testuser</olsa:userName>
         <olsa:actionType>launch</olsa:actionType>
         <olsa:assetId>something:36883</olsa:assetId>
         <olsa:groupCode>company</olsa:groupCode>
      </olsa:GetMultiActionSignOnUrlRequest>
   </soapenv:Body>
</soapenv:Envelope>
I also found the following sample code for creating a soap request, but I'm not sure how to expand/correlate the sample code with the above example.
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.Source;

public class SOAPRequest {

  public static void main(String[] args) throws Exception {
  
    SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope soapEnvelope = soapPart.getEnvelope();

    SOAPHeader soapHeader = soapEnvelope.getHeader();
    SOAPHeaderElement headerElement = soapHeader.addHeaderElement(soapEnvelope.createName("Signature", "SOAP-SEC", "http://schemas.xmlsoap.org/soap/security/2000-12"));

    SOAPBody soapBody = soapEnvelope.getBody();
    soapBody.addAttribute(soapEnvelope.createName("id", "SOAP-SEC","http://schemas.xmlsoap.org/soap/security/2000-12"), "Body");
    Name bodyName = soapEnvelope.createName("FooBar", "z", "http://example.com");
    SOAPBodyElement gltp = soapBody.addBodyElement(bodyName);

    Source source = soapPart.getContent();

  }
}
It looks like there's a main envelope, then two envelopes inside that one?
wsse are elements?
wsu are attributes?
Or do wsse and wsu really mean anything?

Any help is greatly appreciated.

James

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points