> I'm working with ColdFusion 9.0 trying to communicate with web services that 
> our state has set up. I use cfhttp tag to submit SOAP request which looks 
> like this:
>
> <cfhttp method="POST" 
> url="http://167.21.60.200/Delaware.ICIS.XmlFiling..Services/Service.svc"; 
> useragent="gSOAP/2.8" result="httpResponse">
>        <cfhttpparam type="header" name="content-type" value="text/xml">
>        <cfhttpparam type="header" name="charset" value="utf-8">
>        <cfhttpparam type="header" name="content-length" 
> value="#len(signOnSoap)#">
>        <cfhttpparam type="header" name="connection" value="close">
>        <cfhttpparam type="header" name="accept-encoding" 
> value="no-compression" />
>       <cfhttpparam type="header" name="SOAPAction" 
> value="Delaware.ICIS.XmlFiling.Services/FilingService/FileCheckAgentAccountBalanceImmediate">
>          <cfhttpparam type="xml"  value="#trim(ckBalRequest)#">
> </cfhttp>

My first question is, have you tried using CFINVOKE to call the web
service? That doesn't always work, but it's specifically intended to
invoke SOAP services.

> Where ckBalRequest is an xml variable created according to the web service 
> provider specifications. I have no problem getting
> the request to them and receiving the response. However, while the response 
> should be an XML variable as well, when I tried to
> use XMLParse(httpReponse.FileContent), CF gave me an error:  An error occured 
> while Parsing an XML document. Content is
> not allowed in prolog.
> So, tried cfdump to see the response I was getting. Then I got the following 
> error: java.io.ByteArrayOutputStream.
> While researching about this error, I came upon suggestion to use 
> DeserializeJSON function for the response. Now I received
> this error which is something within the response:
>
> JSON parsing failure at character 2:'-' in 
> --uuid:e2f0c19a-df5f-4570-88f2-b641a09178ee+id=34 ...
>
> Here the actual response that the state's  web service is sending me, but 
> ColdFusion keeps having trouble seeing it as a structure:
>
> --uuid:e2f0c19a-df5f-4570-88f2-b641a09178ee+id=34
> Content-ID: <http://tempuri.org/0>
> Content-Transfer-Encoding: 8bit
> Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
>
> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/";>
> <s:Header>
> <h:agentNumber 
> xmlns:h="Delaware.ICIS.XmlFiling.Services">9020288</h:agentNumber>
> <h:agentPONumber 
> xmlns:h="Delaware.ICIS.XmlFiling.Services">NoPOforThisTrans</h:agentPONumber>
> <h:attentionLine xmlns:h="Delaware.ICIS.XmlFiling.Services">Attn: Dan's 
> Listner</h:attentionLine>
> <h:fileDateTime 
> xmlns:h="Delaware.ICIS.XmlFiling.Services">20130509T11:25:50:9196</h:fileDateTime>
> <h:packetNumber 
> xmlns:h="Delaware.ICIS.XmlFiling.Services">9020288_20130107T1623410102</h:packetNumber>
> <h:receivedDateTime 
> xmlns:h="Delaware.ICIS.XmlFiling.Services">20130107T16:23:41:3116</h:receivedDateTime>
> <h:successful xmlns:h="Delaware.ICIS.XmlFiling.Services">true</h:successful>
> </s:Header>
> <s:Body>
> <checkAgentAccountBalanceResponse xmlns="Delaware.ICIS.XmlFiling.Services">
> <accountBalance>797250.4162</accountBalance>
> <fundsReserved>254873.2338</fundsReserved>
> <availableBalance>542377.1824</availableBalance>
> </checkAgentAccountBalanceResponse>
> </s:Body>
> </s:Envelope>
> --uuid:e2f0c19a-df5f-4570-88f2-b641a09178ee+id=34
>
> When I simply display the response by placing on the page 
> <cfoutput>#httpResponse.FileContent#</cfoutput>, I get this:
>
> --uuid:e2f0c19a-df5f-4570-88f2-b641a09178ee+id=34 Content-ID: 
> Content-Transfer-Encoding: 8bit Content-Type:
> application/xop+xml;charset=utf-8;type="text/xml" 
> 9020288NoPOforThisTransAttn: Dan's
> Listner20130509T11:25:50:91969020288_20130509T112542035120130509T11:25:50:9196true789222.
> 1662261386.2338527835.9324 --uuid:e2f0c19a-df5f-4570-88f2-b641a09178ee+id=34--
>
> As you can see all of the headers are compressed then, and it's nearly 
> impossible to extract the values. So I need to have the
> response in a structure that would give me access to the values (and so that 
> I know what they are for me to use them correctly).

The reason all of the headers are compressed then is that the browser
isn't going to show you tags that it doesn't know how to parse, and
you're not outputting a well-formed XML document.

There are several problems here. First, it appears that your response
is part of a MIME multipart message, and you're including the message
headers and the boundary markers (the lines that denote the beginning
and end of the part - the two lines at the very top and bottom that
contain "--uuid ..."). You need to remove those lines, and the first
three lines after the first boundary marker which are part of the
response header and not the response body. Those lines are the content
that's not allowed in the prolog - the prolog is the part before your
root XML element, and typically contains a DTD if it exists at all.

After that - when you just have the parts that begin and end with
<s:Envelope> - you'll have a well-formed XML document. You can
probably parse that just fine with XMLParse.

> So far  DeserializeJSON was the only function that actually displayed headers 
>  in somewhat XML structure, but it has trouble
> with unique identifier (which is a unique identifier for the session) in the 
> beginning of response. Simply trying to remove it from the
> response by using ColdFusion's Replace() isn't working at all. It's still 
> there.

I'm not sure why you'd be using DeserializeJSON for this - it's for
parsing JSON, not XML.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:355687
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to