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="" xmlns:soapenv="">
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="">
         <wsu:Timestamp wsu:Id="Timestamp-15" xmlns:wsu="">
         <wsse:UsernameToken wsu:Id="UsernameToken-14" xmlns:wsu="">
            <wsse:Password Type="">hDLu/mTTJXFtCsxjeufx097Hry4=</wsse:Password>
            <wsse:Nonce EncodingType="">SIM5WxaZFKdAK/gHXvNUww==</wsse:Nonce>
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", ""));

    SOAPBody soapBody = soapEnvelope.getBody();
    soapBody.addAttribute(soapEnvelope.createName("id", "SOAP-SEC",""), "Body");
    Name bodyName = soapEnvelope.createName("FooBar", "z", "");
    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.



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