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
jturkingtonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.