4 Replies Latest reply on Dec 30, 2008 3:59 AM by Newsgroup_User

    XML Query

    patord
      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
        • 1. Re: XML Query
          Level 7
          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
          • 2. Re: XML Query
            Mark Wheeler Level 1
            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
            • 3. Re: XML Query
              Kronin555 Level 1
              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>
              • 4. Re: XML Query
                Level 7
                Mark Wheeler wrote:
                > 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?

                If you more then a few records then I recommend using the Java
                StringBuffer class when doing the concatenation (just google
                "stringBuffer coldfusion"), it's quite faster.

                --
                Mack