Skip to main content
Participant
December 29, 2008
Question

XML Query

  • December 29, 2008
  • 4 replies
  • 427 views
Hi

Hope everyone is having a great break and christmas. Unfortunately I am back at work and have a query, hopefully to gain some understanding about some xml webservices I need to send data to. Using a 3rd party tool I have figured out the request data the webservice is looking for as below.

My question is, using coldfusion code, ie xmlnew(), XMLElemNew(). or other functions How would I create the <tns: and <soap: info in the header, and as a rule of thumb is this information required by the webservice (<tns:Surname /> as opposed to <Surname />) if that makes sense. I would ask the provider this question but nobody available at the moment. ;)

Cheers

MW
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Participating Frequently
December 30, 2008
quote:

...as a rule of thumb is this information required by the webservice (<soap:Body>, <tns:...>)


Yes. XML entity names with a colon in them are within a namespace. In this case, this line:
<soap:Envelope xmlns:soap=" http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:tns= http://ws.com/webservice>

sets up 4 namespaces. soap, xsi, xsd, and tns. The soap namespace is common to any soap-based web service. The tns namespace is specific to this webservice, or maybe generic across all webservices that this specific company has.

Be sure you include _everything_ that is in this snippet. You can't exclude any of it (except, of course, the XML declaration).

<cfxml variable="mySoapRequest">
<soap:Envelope xmlns:soap=" http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:tns=" http://ws.com/webservice">
<soap:Body>
<tns:CreateAccountV1>
<tns:AccountCoreDetails>
<tns:OrganisationCode>CODE HERE</tns:OrganisationCode>
<tns:Surname />
</tns:AccountCoreDetails>
</tns:CreateAccountV1>
</soap:Body>
</soap:Envelope>
</cfxml>
Inspiring
December 29, 2008
patord wrote:
> Hi
>
> Hope everyone is having a great break and christmas. Unfortunately I am back
> at work and have a query, hopefully to gain some understanding about some xml
> webservices I need to send data to. Using a 3rd party tool I have figured out
> the request data the webservice is looking for as below.
>
> My question is, using coldfusion code, ie xmlnew(), XMLElemNew(). or other
> functions How would I create the <tns: and <soap: info in the header, and as a
> rule of thumb is this information required by the webservice (<tns:Surname />
> as opposed to <Surname />) if that makes sense. I would ask the provider this
> question but nobody available at the moment. ;)

There's no need to use XMLNew and friends. You can use plain old
concatenation:
<cfsavecontent variables="xmlBody">
<tns:CreateAccountV1>
<tns:AccountCoreDetails>
<tns:OrganisationCode>CODEHERE</tns:OrganisationCode>
<tns:Surname>#surname#</tns:Surname>
</tns:AccountCoreDetails>
</tns:CreateAccountV1>
</cfsavecontent>

--
Mack
Participant
December 29, 2008
Thanks for that, well I should have mentioned that I am going to be querying a few thousand records may be upto 10,000 with a possible 225 elements, what would be the best way to be able to do this and what is the limit for coldfusion creating each element looping through a query?

MW