Skip to main content
February 17, 2010
Question

Capturing XML to be sent to a Web Service

  • February 17, 2010
  • 2 replies
  • 1848 views

I need to generate the XML to be sent to a cfc remote function (web service)-- but not actually send the XML!

It is easy to use <cfinvoke ...> pointing to the WSDL to actually send the XML, but I can't do that.

What I need to do is capture the XML that would be sent to the service and store it in a database record in an ntext field along with the URL of the web service.

Then a second process will do the actual transmission of the XML to the URL.

(The reason is that the transmission MUST happen and I want to isolate the user of the service from the generic asynchronous process that will do the actual transmission repeatedly until it succeeds.  The user stores the web service URL and data in a table which a second asynchronous process then attempts to deliver until successful.)

So, how do I use <cfinvoke ...><cfinvokeargument...>...</cfinvoke> (or some other process) to grab the XML that would be sent to the web service without actually sending it?

I also don't want to simply pass all the information to the asynchronous process and let it do the <cfinvoke>. This adds processing to store all the information (and there is a lot of it) into the table and then collect the information from the table and build the XML for each attempt.  This also adds intelligence to the generic asynchronous process it doesn't need to possess.

I suspect there is a simple solution I'm not seeing because this is clearly something commonly needed.

This topic has been closed for replies.

2 replies

BKBK
Adobe Expert
February 17, 2010

Here is a possible scenario.

1) Create database table name: webServiceXml
Columns: xmlArgID, userID, url, xmlArg, dateSaved, dateSent

xmlArgID is the primary key.
Datesaved and dateSent are datetimes.
The dateSent will be filled only after the XML is sent. So, the column dateSent can be null; the other columns are non-null.

2) The initial input page contains the query to save the XML argument:

<cfquery name="saveArg" datasource>
insert into webServiceXml values... etc., etc.
</cfquery>

Don't forget to use cfqueryparam

3) As TiGGi has suggested, create a scheduled task that would, at predetermined times:

(i) run a query to get the xml, for example
<cfquery name="getArg" datasource>
select xmlArg
from webServiceXml
where userID=... and datesaved=...
</cfquery>

(ii) use the cfinvoke tag to invoke the web service, with argument getArg.xmlArg

(iii) run a query to record the date of the web service invocation
<cfquery name="savedate" datasource>
update webServiceXml
set dateSent = #createODBCDatetime(now())#
where userID=... and datesaved=....
</cfquery>

Done.

New Participant
February 17, 2010

Hi,

I have no problem storing the XML in a table and using it.

What I don't know how to do is get the XML to be stored in the table.  The <cfinvoke> doesn't let me see the XML is sends to the web service.  It just sends it.  How do I NOT send the XML to the web service, but just acquire it?

I can call the WSDL and see the definition language describing how to build the XML to be sent.  That doesn't help.  CFInvoke actually DOES build the outgoing XML.  I want THAT XML.  How do I get it so that I can place it in the database table instead of sending it to the web service right away?

That is what I don't know how to do: capture the outgoing XML.  It is probably very easy and that is why no one is explaining it to me.  They are assuming I already know how to do that part.

-Al Baker

New Participant
February 22, 2010

Well,  I'm guessing no one, even at Adobe, knows how to generate the XML that is going to the Web

Service based on the WSDL definition.

I'd welcome anyone who can prove me wrong and provide a method of capturing the XML that would be sent to a Web Service based on a WSDL.

This doesn't even have to be within ColdFusion.  A site that will take a WSDL url and generate the XML that would be sent would be great.    I found a site that will take a WSDL URL and present a form that can be filled out, but given the XML, I can plug values into the nodes of the generated XML file without a form.  What I want is the actual outgoing XML.

Inspiring
February 17, 2010

Tell me if I got this right, you want user to be able to generate xml but not send it, and then have a separate process that does not require user input to send this xml?

If this is the case then you can just create a scheduled event that would run this process, grab xml from db, keep trying to send it until success, delete/mark xml  in db on completion.

New Participant
February 17, 2010

Exactly correct and that is the plan.

The problem is that I don't know how to get the xml to be placed in the database record to be sent later.

<cfinvoke> sends the xml and doesn't present it as a variable that I can store in the database.

So, how do I get the xml that would be sent to the web service instead of sending it to the web service?

(This is Al Baker accessing via a different email address.)