Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 838
  • Last Modified:

CFXML Content Type Header Issues

Having issues trying to send XML by a HTTP Request i am receving the following errors once I post to the URL: -

HTTP/1.1 200 OK Expires: Thu, 11 Nov 2004 09:24:16 GMT Content-Type: text/xml Connection: close Date: Thu, 11 Nov 2004 09:25:16 GMT Cache-control: private Content-Length: 1164 Server: Microsoft-IIS/5.0

Processed on 11 Nov 2004 at 9:25:16 AM Please set the [Content-Type] header to either [text/xml] or [text/csv] not [text/xml; charset=utf-8] 0 job(s) successfully uploaded into the system (0 seconds) 0 job(s) were supplied for processing. 0 0 There were Errors. Please check the messages. 0 0

My Code is as follows :  -

<cfxml variable="XMLStuff" casesensitive="yes">
      <XMLRoot>
            <Header>
                  <Source>Source</Source>
                  <MasterAccount>blah blah</MasterAccount>
            </Header>
                </XMLRoot>
</cfxml>

<cfhttp method="POST" url="http://www.website/upload.asp">
      <cfhttpparam type="xml" value="#ToString(ConkersXML)#">
</cfhttp>

<cfoutput>
      #cfhttp.header#
      <br><br>
      #cfhttp.fileContent#
</cfoutput>

I think the problem is down to the CFXML tag sticking the [Content-Type] header to [text/xml; charset=utf-8] instead of [text/xml]

Any help would be greatly appreciated

Best Regards

Jonathan
0
jturkington
Asked:
jturkington
  • 6
  • 4
  • 2
  • +1
1 Solution
 
kkhippleCommented:
have you tried the following:

<CFSETTING showdebugoutput="No">

<CFCONTENT type="text/xml">
<CFOUTPUT><!--- PUT WHAT YOU WANT TO OUTPUT HERE ---></CFOUTPUT>



ref: http://www.macromedia.com/support/coldfusion/ts/documents/devnet_watermark.htm
0
 
jturkingtonAuthor Commented:
Thanks for the quick response, I am using the CF Enterprise Edition so it shouldnt affect it.

As i mentioned earlier i am a newbie starting out  with XML, am i missing something really obvious

The nearest progress I have come to with the {content type] header was to add the following line of code to the CFHTTP tag:  -

<cfhttp method="POST" url="http://www.upload.conkers.net/upload.asp">
      <cfhttpparam type="HEADER" name="Content-Type" value="text/xml; charset=utf-16">
      <cfhttpparam type="xml" value=#mynewvar#>
</cfhttp>

This changed the error message to the follwoing: -

Processed on 11 Nov 2004 at 2:06:32 PM Please set the [Content-Type] header to either [text/xml] or [text/csv] not [text/xml; charset=utf-16,text/xml; charset=utf-8] 0 job(s) successfully uploaded into the system (0 seconds) 0 job(s) were supplied for processing. 0 0 There were Errors. Please check the messages. 0 0

Why is it appending instead of overwriting the content type header ??

thanks for your help

0
 
jturkingtonAuthor Commented:
I think I know what the problem is, the CFHTTP tag is sending the charset=UTF-8 by default, is there any way of removing the charset attribute when posting ?

So close but yet so far !!
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
INSDivision6Commented:
Try to use <cfhttpparam type="body" ...>  for XML and <cfhttpparam type="header" ...> to set "text/xml" content type.
0
 
shooksmCommented:
Try setting a blank charset attribute for the CFHTTP tag:

<cfhttp method="POST" url="http://www.upload.conkers.net/upload.asp" charset="">
     <cfhttpparam type="HEADER" name="Content-Type" value="text/xml">
     <cfhttpparam type="xml" value=#mynewvar#>
</cfhttp>
0
 
jturkingtonAuthor Commented:
Thanks for the response Guys

Setting the charset="" only generates the following error, and sometimes a connection error screen : -

Processed on 11 Nov 2004 at 2:06:32 PM Please set the [Content-Type] header to either [text/xml] or [text/csv] not [text/xml; charset=] 0 job(s) successfully uploaded into the system (0 seconds) 0 job(s) were supplied for processing. 0 0 There were Errors. Please check the messages. 0 0

Any other ideas or have I hit a coldfusion limitation ?

Jonny
0
 
shooksmCommented:
If you are running Cold Fusion on a Windows box, you might try something like this:

<cfxml variable="ConkersXML" casesensitive="yes">
     <XMLRoot>
          <Header>
               <Source>Source</Source>
               <MasterAccount>blah blah</MasterAccount>
          </Header>
                </XMLRoot>
</cfxml>

<!--- Create the Microsft.XMLHTTP object to handle sending the XML data to the Web Service --->
<cftry>
      <cfobject action="connect" class="Microsoft.XMLHTTP" name="objXMLHTTP" type="com">
      <cfcatch type="any">
            <cfobject action="create" class="Microsoft.XMLHTTP" name="objXMLHTTP" type="com">
      </cfcatch>
</cftry>

<cfset objXMLHTTP.Open("POST", "http://www.upload.conkers.net/upload.asp", false)>
<cfset objXMLHTTP.setRequestHeader("Content-Type", "text/xml")>
<cfset objXMLHTTP.send(ToString(ConkersXML))>
0
 
INSDivision6Commented:
Did you try <cfhttpparam type="body" ...>, as I suggested?  If it doesn't work, you can always use the tag below.  It will work for sure.

http://www.cftagstore.com/tags/cfxhttp5.cfm
0
 
jturkingtonAuthor Commented:
I havnt as yet tried the <cfhttpparam type="body" ...> as i am unsure as to how this will help me disable the charset attribute from being sent ?


Any advice or example code would be greatly appreciated INSDivision6

Thanks again

Jonny
0
 
INSDivision6Commented:
Well, when you use <cfhttpparam type="XML" ...> CF "friendly" adds "Content-type:" header to your CFHTTP request.  When you use <cfhttpparam type="body" ...>, it shouldn't do this, because the content type is not defined yet.  Therefore, your

<cfhttpparam type="header" name="Content-Type" value="text/xml">

should create the correct content type header without charset attribute, I guess.
0
 
jturkingtonAuthor Commented:
Interesting now receiving the following error message : -

Processed on 15 Nov 2004 at 5:53:10 PM Please set the [Content-Type] header to either [text/xml] or [text/csv] not [application/octet-stream] 0 job(s) successfully uploaded into the system (0 seconds) 0 job(s) were supplied for processing. 0 0 There were Errors. Please check the messages. 0 0

with this code : -

<cfhttp method="POST" url="http://www.upload.conkers.net/upload.asp">
      <cfhttpparam type="body" value=#mynewvar#>
</cfhttp>
0
 
INSDivision6Commented:
You have to also execute:

<cfhttpparam type="header" name="Content-Type" value="text/xml">

0
 
jturkingtonAuthor Commented:
Sorry for the last post I wasnt thinking !

I added in the custom header line along with the body and it works !!

Thankyou to everyone who posted in this thread

INSDivision6 the points are yours !!

Best Regards

Jonathan
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now