IBM Worklight v5.0.5 > Develop IBM Worklight applications > Develop the server side of an IBM Worklight application

Encode a SOAP XML envelope within a request body


To invoke a SOAP-based service in an HTTP adapter, encode the SOAP XML envelope within the request body.

Encoding XML within JavaScript using XML E4X is officially part of JavaScript 1.6. This technology can be used to encode any XML document, not necessarily SOAP envelopes.


Example

var request =
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <requestMessageObject xmlns="http://acme.com/ws/">
            <messageHeader>
                <version>1.0</version>
                <originatingDevice>{originatingDevice}</originatingDevice>
                <originatingIP>
                    {WL.Server.configuration["local.IPAddress"]}
                </originatingIP>
                <requestTimestamp>
                    {new Date().toLocaleString()}
                </requestTimestamp>
            </messageHeader>
            <messageData>
                <context>
                    <userkey>{userKey}</userkey>
                    <sessionid>{sessionid}</sessionid>
                </context>
            </messageData>
        </requestMessageObject>
    </S:Body>
</S:Envelope>;

Use the WL.Server.signSoapMessage() method only inside a procedure declared within an HTTP adapter. It signs a fragment of the specified envelope with id wsId, using the key in the specified keystoreAlias, inserting the digital signature into the input document.

To use WL.Server.signSoapMessage() API when running IBM Worklight on IBM WAS you might need to add a JVM argument that instructs WebSphere to use a specific SOAPMessageFactory implementation instead of a default one. To do this, go to...

...and provide the following argument under Generic JVM arguments, typing in the code phrase exactly as it is presented here:

Restart the JVM.

This workaround is only for IBM WebSphere.


Parent Develop the server side of an IBM Worklight application


Related information:

XML E4X





+

Search Tips   |   Advanced Search