4 Replies Latest reply on Jun 5, 2007 10:29 AM by insuractive

    Help with AddSOAPRequestHeader method

      I have the following XML that i need to add to the SOAP header before calling a webservice that is using WS-Security (hence the added headers)

      <wsse:Security soap:mustUnderstand="1">
      <wsu:Timestamp wsu:Id="Timestamp-15360f9f-15f3-466d-a27f-b7f0712304d6">
      <wsse:UsernameToken wsu:Id="SecurityToken-d1370982-78d0-42f6-b4c8-1b2436005cde">
      <wsse:Password Type=" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#Passwor dText">mypass</wsse:Password>

      How do i add this using the AddSOAPRequestHeader?
      I tried creating an XML object and send that, but XMLParse keeps telling that a 'wss' namespace isnt defined, when i add that
      it cries about the "soap:envelope" namespace and so on.

      Im clueless how to use AddSOAPRequestHeader here since much of these are attributes to tags and not just values

      please help
        • 1. Re: Help with AddSOAPRequestHeader method
          Did you ever figure out how to do this? I have the same question.
          • 2. Re: Help with AddSOAPRequestHeader method
            I don't know if this is the best way to do it, but after much trial and error, I've come up with something that works.

            myObj = createObject("webservice","path/to/wsdl");
            headerElement = createObject("java", "org.apache.axis.message.SOAPHeaderElement");
            headerElement.init(" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:Security");
            • 3. Re: Help with AddSOAPRequestHeader method
              DonnaB Level 1
              Thanks for sharing this. Maybe it can help me eventually. Unfortunately, the wsdl for the webservice I'm trying to consume includes the following under <wsdl:definitions... />:

              xmlns:ns8=" http://www.w3.org/2000/09/xmldsig#"

              For some reason, this prevents me from even instantiating the webservice. The error I get is:

              Could not generate stub objects for web service invocation.... java.io.IOException: Type { http://www.w3.org/2000/09/xmldsig#} Reference is referenced but not defined.

              I'm guessing that there is either some Java library I need, or CF is barfing on the #. Anyway, I never get far enough to add the headers.

              Ideas from anyone on resolving this part of my problem would be most welcome.
              • 4. Re: Help with AddSOAPRequestHeader method
                insuractive Level 3

                You can try hosting the wsdl on your local machine, which would allow you to play around with the actual contents (try removing the # sign, or using a different URL for ns8?). As long as the wsdl has a service port element pointing to the actual webservice URL it doesn't actually matter where the WSDL file resides.

                If this is the way you decide to go, I would recommend a scheduled task that downloads the ACTUAL WSDL file on a regular basis, makes the changes and then saves it locally to make sure you are using the latest version.

                Also, this issue seems unique enough that it really should have its own thread. Post to a new topic - you'll probably get a lot more suggestions