Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to generate XML soap message

317 views
Skip to first unread message

anj patnaik

unread,
Feb 6, 2012, 1:45:58 PM2/6/12
to
Hello,

I would like to be able to generate a XML message like the one below
dynamically, i,e from variables/list params. I briefly looked at
tclsoap and the basic example didn't work and still researching tclws.
The latter requires wsdl file parsing and the WSDL files I have are
quite complex and nested.

So, I was wondering about tdom, but the examples seem to be more DTD
oriented.

Any pointers appreciated! Thanks.

Here is a sample XML request that I need to be able generate from
variables.

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:v1="http://www.tmforum.org/mtop/fmw/xsd/hdr/v1"
xmlns:v11="http://www.tmforum.org/mtop/rtm/xsd/ar/v1"
xmlns:v12="http://www.tmforum.org/mtop/fmw/xsd/nam/v1"
xmlns:v13="http://www.tmforum.org/mtop/nra/xsd/com/v1"
xmlns:v14="http://www.tmforum.org/mtop/nra/xsd/prc/v1">
<soapenv:Header>
<v1:header>
<v1:destinationURI>http://localhost:9006/mtosi/rtm/
AlarmRetrieval</v1:destinationURI>
<v1:communicationStyle>RPC</v1:communicationStyle>
<v1:activityName>getActiveAlarms</v1:activityName>
<v1:msgName>GetActiveAlarmsRequest</v1:msgName>
<v1:senderURI>http://localhost:9009</v1:senderURI>
<v1:msgType>REQUEST</v1:msgType>
<v1:communicationPattern>MultipleBatchResponse</
v1:communicationPattern>
<v1:requestedBatchSize>1000</v1:requestedBatchSize>
</v1:header>
</soapenv:Header>
<soapenv:Body>
<v11:getActiveAlarmsRequest>
<v11:filter>
<v11:perceivedSeverityList>

<v13:perceivedSeverity>CLEARED</
v13:perceivedSeverity>
</v11:perceivedSeverityList>
</v11:filter>
</v11:getActiveAlarmsRequest>
</soapenv:Body>
</soapenv:Envelope>

Aric Bills

unread,
Feb 6, 2012, 2:33:30 PM2/6/12
to
Example output is helpful. Can you also give the example input that's
supposed to produce it?

anj patnaik

unread,
Feb 6, 2012, 3:27:25 PM2/6/12
to

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<header xmlns:ns13="http://www.tmforum.org/mtop/rtm/xsd/ar/v1"
xmlns:ns12="http://www.tmforum.org/mtop/nrb/xsd/lay/v1"
xmlns:ns11="http://www.tmforum.org/mtop/rtm/xsd/ac/v1"
xmlns:ns10="http://www.tmforum.org/mtop/fmw/xsd/msg/v1"
xmlns:ns9="http://www.tmforum.org/mtop/fmw/xsd/cornot/v1"
xmlns:ns8="http://www.tmforum.org/mtop/nra/xsd/com/v1"
xmlns:ns7="http://www.tmforum.org/mtop/nra/xsd/prc/v1"
xmlns:ns6="http://www.tmforum.org/mtop/nra/xsd/alm/v1"
xmlns:ns5="http://www.tmforum.org/mtop/fmw/xsd/nam/v1"
xmlns:ns4="http://www.tmforum.org/mtop/fmw/xsd/ei/v1"
xmlns:ns3="http://www.tmforum.org/mtop/fmw/xsd/cei/v1"
xmlns:ns2="http://www.tmforum.org/mtop/fmw/xsd/gen/v1" xmlns="http://
www.tmforum.org/mtop/fmw/xsd/hdr/v1">
<activityName>getActiveAlarms</activityName>
<msgName>getActiveAlarmsResponse</msgName>
<msgType>RESPONSE</msgType>
<senderURI>http://wcars057:9006/mtosi/rtm/AlarmRetrieval</
senderURI>
<destinationURI>http://localhost:9009</destinationURI>
<activityStatus>SUCCESS</activityStatus>
<communicationPattern>MultipleBatchResponse</
communicationPattern>
<communicationStyle>RPC</communicationStyle>
<requestedBatchSize>2</requestedBatchSize>
<batchSequenceEndOfReply>false</batchSequenceEndOfReply>
<iteratorReferenceURI>http://wcars057:9006/mtosi/rtm/
AlarmRetrieval/32</iteratorReferenceURI>
<timestamp>2012-02-06T03:15:59.783-00:05</timestamp>
</header>
</S:Header>
<S:Body>
<ns13:getActiveAlarmsResponse xmlns:ns13="http://www.tmforum.org/
mtop/rtm/xsd/ar/v1" xmlns:ns12="http://www.tmforum.org/mtop/nrb/xsd/
lay/v1" xmlns:ns11="http://www.tmforum.org/mtop/rtm/xsd/ac/v1"
xmlns:ns10="http://www.tmforum.org/mtop/fmw/xsd/msg/v1"
xmlns:ns9="http://www.tmforum.org/mtop/fmw/xsd/cornot/v1"
xmlns:ns8="http://www.tmforum.org/mtop/nra/xsd/com/v1"
xmlns:ns7="http://www.tmforum.org/mtop/nra/xsd/prc/v1"
xmlns:ns6="http://www.tmforum.org/mtop/nra/xsd/alm/v1"
xmlns:ns5="http://www.tmforum.org/mtop/fmw/xsd/nam/v1"
xmlns:ns4="http://www.tmforum.org/mtop/fmw/xsd/ei/v1"
xmlns:ns3="http://www.tmforum.org/mtop/fmw/xsd/cei/v1"
xmlns:ns2="http://www.tmforum.org/mtop/fmw/xsd/gen/v1" xmlns="http://
www.tmforum.org/mtop/fmw/xsd/hdr/v1">
<ns6:alarm>
<ns3:notificationId>1630</ns3:notificationId>
<ns3:sourceTime>2012-01-30T10:19:59.633-00:05</
ns3:sourceTime>
<ns4:objectType>AID</ns4:objectType>
<ns4:objectName>
<ns5:rdn>
<ns5:type>OS</ns5:type>
<ns5:value>Ciena</ns5:value>
</ns5:rdn>
</ns4:objectName>
<ns4:osTime>2012-01-30T10:19:59.633-00:05</ns4:osTime>
<ns6:isClearable>true</ns6:isClearable>
<ns6:aliasNameList>
<ns2:alias>
<ns2:aliasName>nativeSrcEntityId</ns2:aliasName>
<ns2:aliasValue>Mediation</ns2:aliasValue>
</ns2:alias>
</ns6:aliasNameList>
<ns6:probableCause>
<ns7:probableCause>VENDOR_EXT</ns7:probableCause>
</ns6:probableCause>
<ns6:additionalText>Communication Failed with
ESM_umsint01</ns6:additionalText>
<ns6:perceivedSeverity>CLEARED</ns6:perceivedSeverity>
<ns6:serviceAffecting>NON_SERVICE_AFFECTING</
ns6:serviceAffecting>
</ns6:alarm>
<ns6:alarm>
<ns3:notificationId>1631</ns3:notificationId>
<ns3:sourceTime>2012-01-30T10:22:26.993-00:05</
ns3:sourceTime>
<ns4:objectType>AID</ns4:objectType>
<ns4:objectName>
<ns5:rdn>
<ns5:type>OS</ns5:type>
<ns5:value>Ciena</ns5:value>
</ns5:rdn>
</ns4:objectName>
<ns4:osTime>2012-01-30T10:22:26.993-00:05</ns4:osTime>
<ns6:isClearable>true</ns6:isClearable>
<ns6:aliasNameList>
<ns2:alias>
<ns2:aliasName>nativeSrcEntityId</ns2:aliasName>
<ns2:aliasValue>Synchronization Coordinator</
ns2:aliasValue>
</ns2:alias>
</ns6:aliasNameList>
<ns6:probableCause extension="Loss Of Synchronization">
<ns7:probableCause>VENDOR_EXT</ns7:probableCause>
</ns6:probableCause>
<ns6:nativeProbableCause>Loss Of Synchronization</
ns6:nativeProbableCause>
<ns6:additionalText>Synchronization
Failure:ALPHA_3930_3:PSM</ns6:additionalText>
<ns6:perceivedSeverity>CLEARED</ns6:perceivedSeverity>
<ns6:serviceAffecting>NON_SERVICE_AFFECTING</
ns6:serviceAffecting>
</ns6:alarm>
<ns6:alarm>
<ns3:notificationId>1632</ns3:notificationId>
<ns3:sourceTime>2012-01-30T10:22:27.493-00:05</
ns3:sourceTime>
<ns4:objectType>AID</ns4:objectType>
<ns4:objectName>
<ns5:rdn>
<ns5:type>OS</ns5:type>
<ns5:value>Ciena</ns5:value>
</ns5:rdn>
</ns4:objectName>
<ns4:osTime>2012-01-30T10:22:27.493-00:05</ns4:osTime>
<ns6:isClearable>true</ns6:isClearable>
<ns6:aliasNameList>
<ns2:alias>
<ns2:aliasName>nativeSrcEntityId</ns2:aliasName>
<ns2:aliasValue>Synchronization Coordinator</
ns2:aliasValue>
</ns2:alias>
</ns6:aliasNameList>
<ns6:probableCause extension="Loss Of Synchronization">
<ns7:probableCause>VENDOR_EXT</ns7:probableCause>
</ns6:probableCause>
<ns6:nativeProbableCause>Loss Of Synchronization</
ns6:nativeProbableCause>
<ns6:additionalText>Synchronization Failure:5410:PSM</
ns6:additionalText>
<ns6:perceivedSeverity>CLEARED</ns6:perceivedSeverity>
<ns6:serviceAffecting>NON_SERVICE_AFFECTING</
ns6:serviceAffecting>
</ns6:alarm>
</ns13:getActiveAlarmsResponse>
</S:Body>
</S:Envelope>

Alexandre Ferrieux

unread,
Feb 6, 2012, 3:43:19 PM2/6/12
to
When I see XML used this way, I am suddenly nostalgic of ASN.1...
(I know it is not your fault, and I have a precise idea of where the
dim-witted designers of SOAP belong ;-)

-Alex

anj patnaik

unread,
Feb 6, 2012, 3:26:30 PM2/6/12
to
You want the output and input, right?

Ok, I have attached the output when the input above has a
requestedBatchSize of 3.

Note that I am only interested in building input from vars/list. The
output will be probably be a dump of what's fetched from http::data.

Aric Bills

unread,
Feb 6, 2012, 5:44:34 PM2/6/12
to
Sorry if I wasn't clear enough before. In your original post, you
showed us an example of the XML file you wanted to generate. You said
you want to generate this from a set of variables or list of
parameters. Can you give us the variables or parameters that are
supposed to produce the XML file in your original post?

anj patnaik

unread,
Feb 6, 2012, 7:07:59 PM2/6/12
to
I'd probably use a list or list of lists to denote the data to be set.

Something like this for the header:

set header { communicationStyle RPC activityName getActiveAlarms
msgType REQUEST ...}

set body {filter {perceivedSeverityList {CLEARED}}}

Note that since SOAP body params are many levels deep I probably need
a list of lists or something.

I am using Tcl 8.4.

THANKS.

Aric Bills

unread,
Feb 7, 2012, 12:45:09 AM2/7/12
to
OK, thanks for clarifying.

tdom does provide functionality for building a DOM tree from a list,
using [$doc appendFromList $list] or [$node appendFromList $list].
appendFromList expects a list with two or three items. If the first
list item is "#text", tdom creates a text node whose contents are the
second item in the list. Otherwise, the first item names the node to
be created, the second item is a list of attribute-value pairs, and
the third item is a list of children; each child should also be a two-
or three-item list. Here's a trivial example:

package require tdom
set booklist {
{book {type fiction} {{#text {Gulliver's Travels}}}}
{book {type nonfiction} {{#text {Tcl and the Tk Toolkit}}}}
}
set bookDocAsList [list books [list] $booklist]
dom createDocumentNode bookdoc
$bookdoc appendFromList $bookDocAsList

This will create a DOM tree corresponding to the following document:

<books>
<book type="fiction">Gulliver's Travels</book>
<book type="nonfiction">Tcl and the Tk Toolkit</book>
</books>

By the way, you can produce the corresponding XML document using

$bookdoc asXML

In the case of your XML document from your original post, you could
create it like this (you'll have to remove the extra newlines inserted
by Google Groups):

package require tdom
dom createDocumentNode doc
$doc appendFromList {soapenv:Envelope {xmlns:soapenv {http://
schemas.xmlsoap.org/soap/ envelope/} xmlns:v1 http://www.tmforum.org/mtop/fmw/xsd/hdr/v1
xmlns:v11 http://www.tmforum.org/mtop/rtm/xsd/ar/v1 xmlns:v12
http://www.tmforum.org/mtop/fmw/xsd/nam/v1 xmlns:v13
http://www.tmforum.org/mtop/nra/xsd/com/v1 xmlns:v14
http://www.tmforum.org/mtop/nra/xsd/prc/v1} {{soapenv:Header {}
{{v1:header {} {{v1:destinationURI {} {{{#text}
http://localhost:9006/mtosi/rtm/AlarmRetrieval}}}
{v1:communicationStyle {} {{{#text} RPC}}} {v1:activityName {}
{{{#text} getActiveAlarms}}} {v1:msgName {} {{{#text}
GetActiveAlarmsRequest}}} {v1:senderURI {} {{{#text} http://localhost:9009}}}
{v1:msgType {} {{{#text} REQUEST}}} {v1:communicationPattern {}
{{{#text} MultipleBatchResponse}}} {v1:requestedBatchSize {} {{{#text}
1000}}}}}}} {soapenv:Body {} {{v11:getActiveAlarmsRequest {}
{{v11:filter {} {{v11:perceivedSeverityList {} {{v13:perceivedSeverity
{} {{{#text} CLEARED}}}}}}}}}}}}}

Does that help?

Gerald W. Lester

unread,
Feb 7, 2012, 10:43:14 AM2/7/12
to
On 2/6/12 12:45 PM, anj patnaik wrote:
> Hello,
>
> I would like to be able to generate a XML message like the one below
> dynamically, i,e from variables/list params. I briefly looked at
> tclsoap and the basic example didn't work and still researching tclws.
> The latter requires wsdl file parsing and the WSDL files I have are
> quite complex and nested.
>
> So, I was wondering about tdom, but the examples seem to be more DTD
> oriented.
>
> Any pointers appreciated! Thanks.
>
> Here is a sample XML request that I need to be able generate from
> variables.

Anj,

tclws uses tdom to build an parse the XML.

You have the following options:


1) Take your several partial WSDLs and make them one full WSDL and use tclws
-- this requires that you be able to read and understand your WSDLs.

2) Generate/parse the the XML using a package such as tdom -- this requires
that you be able to read and understand your WSDLs.

3) Generate/parse the the XML by hand (using format, string functions and
commands) -- this requires that you be able to read and understand your WSDLs.

Note -- there is a common step that you can not skip.

--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+

anj patnaik

unread,
Feb 7, 2012, 11:42:15 AM2/7/12
to
Hi Gerald,

I already tried #1 and sent you several emails as tclws errored out
when parsing the combined wsdl file.

Thanks.

On Feb 7, 10:43 am, "Gerald W. Lester" <Gerald.Les...@KnG-
> | Email: Gerald.Les...@kng-consulting.net                                |
> +------------------------------------------------------------------------+

Gerald W. Lester

unread,
Feb 7, 2012, 4:15:41 PM2/7/12
to anj patnaik
On 2/7/12 10:42 AM, anj patnaik wrote:
> Hi Gerald,
>
> I already tried #1 and sent you several emails as tclws errored out
> when parsing the combined wsdl file.

Anj,

You sent me two (2) emails after combining the WSDLs.

The first one you discovered your error (you were passing a file name to
::WS::ParseWsdl instead of the actual XML).

The second error was after you were passing the XML and the message
indicates it could not find a type -- not likely either it is missing or
there is an XML namespace/alias conflict from when you made the single WSDL.
I said I would look at it but it would take a couple of days to get to it.

The problem here is that the WS you want to use is being presented in a
**VERY** non-standard way *AND* you do not understand the format and content
of a WSDL enough to correct the presentation.

Early on you stated that this was from a "standard body" -- but you have
never said which one or given any relevant URLs.

In short, you are looking for a silver bullet of a particular caliber.


--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+

Gerald W. Lester

unread,
Feb 7, 2012, 4:58:27 PM2/7/12
to anj patnaik
On 2/7/12 3:15 PM, Gerald W. Lester wrote:
> On 2/7/12 10:42 AM, anj patnaik wrote:
>> Hi Gerald,
>>
>> I already tried #1 and sent you several emails as tclws errored out
>> when parsing the combined wsdl file.
>
> Anj,
>
> You sent me two (2) emails after combining the WSDLs.
>
> The first one you discovered your error (you were passing a file name to
> ::WS::ParseWsdl instead of the actual XML).
>
> The second error was after you were passing the XML and the message
> indicates it could not find a type -- not likely either it is missing or
> there is an XML namespace/alias conflict from when you made the single WSDL.
> I said I would look at it but it would take a couple of days to get to it.
>
> The problem here is that the WS you want to use is being presented in a
> **VERY** non-standard way *AND* you do not understand the format and content
> of a WSDL enough to correct the presentation.
>
> Early on you stated that this was from a "standard body" -- but you have
> never said which one or given any relevant URLs.
>
> In short, you are looking for a silver bullet of a particular caliber.

Anj,

Went in looked at the combined WSDL you sent and the "associated" XSDs.

Your WSDL you have several lines that read:
<wsdl:part name="mtopHeader" element="hdr:header"/>

However, you do not have hdr defined as a namespace alias in the WSDL. You
do have hdr defined as a namespace alias in MessageDefinitions.xsd.

Also I noticed that you are doing imports of XSDs you did not send me, such
as LayerRates.xsd.

Lastly a lot of your XSD imports have relative paths such as:
../../../NetworkResourceAssurance/IIS/xsd/CommonTypes.xsd


This means that you really be having a base WSDL at a server with the tree
layout expected. Luckly, TclWs can get around this via the use of:
::WS::Utils::SetOption includeDirectory $xdDirectory


All that being said, IMHO from the things you keep missing you are in over
your head. You may want to bring in a consultant to help you get your job done.
0 new messages