When returning a 500 error response, i want to have a WebDAV XML response like:
<?xml version="1.0" encoding="utf-8" ?>
<D:error xmlns:D="DAV:">
<D:must-be-checked-in/>
</D:error>"""
But instead of <D:must-be-checked-in/> i need some property for "Internal server error" which i could not find in any of the related RFCs. Is there a standard webdav response for server errors? Or an empty response body is ok?
If you don't have anything more specific to tell, an empty response body is just fine.
Related
What is the correct format for sending an HTTP 403 forbidden message?
I'm writing a proxy in c for a homework project that has a content filtering system built in. When my proxy detects that a server's response has certain keywords that are contained in the content blacklist, I would like to send a HTTP 403 Forbidden message.
Currently, I am sending the message as: "HTTP/1.1 403 Forbidden\r\n\r\n" (without the quotes) as per this standard: https://www.rfc-editor.org/rfc/rfc7231#section-6.5.3
When I send this message, the browser doesn't display an error and looks like it's still trying to load the page.
Are there any required header fields for this http message that I missed? Also, is this the correct usage for the 403 error? I couldn't find anything else that would be more fitting, so I chose 403 because the client won't automatically re-request the data.
Thanks in advance for any help!
For those struggling with this issue as I did, you need to make sure to close the socket or set Connection: Close as Sami noted in the comments. I assumed that you could keep it open so they could send another request with http persistent connections, but they will need to open a new connection.
As for the html displayed, you can send a body with the response (make sure you set Content-Length) that contains the html you want displayed.
Finally, here are two references, one to the HTTP response spec, and the other to the Amazon Restful response spec:
https://www.rfc-editor.org/rfc/rfc7231#section-6.5.3
https://developer.amazon.com/docs/amazon-drive/ad-restful-api-response-codes.html
The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' var IsFormValidated='T';
getting this error while consuming .please help
i have tried below code in my webconfig
still getting below errors::::
OPTIONS http://xyz.com/WebService1.asmx/Login 500 (Internal Server Error) jquery.min%201.4.4.js:141
OPTIONS http://xyz.com/WebService1.asmx/Login Origin http://xyz.com is not allowed by Access-Control-Allow-Origin. jquery.min%201.4.4.js:141
XMLHttpRequest cannot load http://xyz.com/WebService1.asmx/Login. Origin http://xyz.com is not allowed by Access-Control-Allow-Origin. Default.aspx:1
First build a working c# client. then compare the request it sends (header + body) to the request your php client sends.
I need to consume a asp.net web service using ColdFusion 8 and return an XML file.
I am able to communicate with asp.net service but am returned an error from the service that basically says the information I passed was not valid.
Here is a run down of my code :
<cfxml variable="soap">
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<cfoutput> <GetSession xmlns="#stagingurl#"></cfoutput>
<strApplicationKey>myappkey</strApplicationKey>
<UID>myuserid</UID>
<arrProperties>
<Property>
<Name>IP</Name>
<Value>127.0.0.1</Value>
</Property>
</arrProperties>
<arrRoles />
</GetSession>
</soap:Body>
</soap:Envelope>
</cfxml>
<cfhttp url="#apiurl#" method="post" result="httpresponse" port="443">
<cfhttpparam type="header" name="content-type" value="text/xml">
<cfhttpparam type="header" name="SOAPAction" value="#mysoapaction#">
<cfhttpparam type="header" name="content-length" value="#len(trim(soap))#">
<cfhttpparam type="header" name="charset" value="utf-8">
<cfhttpparam type="Body" value="#trim(soap)#" name="FileContent"/>
</cfhttp>
<cfdump var="#GetHttpRequestData()#" label="Get Http Request Data" />
Is there a way to preview the information being sent to make sure that ColdFusion is actually sending my XML/SOAP request?
I did use #GetHttpRequestData()# to return some data and within the structure, content is "empty string" and this is where I need help. Should this be empty? This is new for me, but, I guess I expected that my information being passed to the asp.net service would be in there.
FYI - I can see the HTTP and SOAP response fine, I just can not see the request information. How do I view the Request information?
Still trying to determine if the issue is on my end, or theirs and need to gather facts at this point.
Another invaluable tool when working with web services is soapUI. That should definitely be a part of your toolkit as well. You can build your request using soapUI and check the responses. Once you have it working with soapUI you can copy your request into your ColdFusion code.
One thing that I noticed is that your are wrapping your XML in a cfxml tag. I'm not sure if that is messing with your request or not. I typically wrap my XML request in cfsavecontent tags. So you could try changing your code like this:
<cfsavecontent variable="soap">
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<cfoutput> <GetSession xmlns="#stagingurl#"></cfoutput>
<strApplicationKey>myappkey</strApplicationKey>
<UID>myuserid</UID>
<arrProperties>
<Property>
<Name>IP</Name>
<Value>127.0.0.1</Value>
</Property>
</arrProperties>
<arrRoles />
</GetSession>
</soap:Body>
</soap:Envelope>
</cfsavecontent>
The rest of your code can remain the same.
If you're on Windows (or have a windows machine to hand) install Fiddler and start it. It's a proxy that listens on port 8888 by default so in your cfhttp call, add proxyServer="127.0.0.1" and proxyPort="8888" and run your request again.
Just noticed that you're using port 443, so probably SSL. You can enable HTTPS decrypt Tools->Fiddler Options->HTTPS Tab->Decrypt HTTPS traffic. You may then also need to import the Certificate that Fiddler uses into your keystore.
Each request will now show up in Fiddler and you can use the request and response inspectors on the right to look at the exact data going between the servers (the Raw tab shows the data unchanged). This has saved me so many times and is now part of my standard toolkit.
In your particular case, is there a reason you're not using CreateObject("webservice","http://....") . I'm assuming that it's not playing well with a .Net-based webservice?
Also, the call to GetHttpRequestData() shows the request you made to your test page, not the HTTP call you made to the test webservice. Unfortunately, CFHTTP doesn't return any structure showing the full HTTP request details it used. I think that would be a pretty sound feature request, as at the moment, you'll have to use a tool like fiddler or wireshark to see what was sent.
Simple issue with dot net is, it cannot processs XML document created by coldfusion. To return XML to dot net, convert into string format (XMLvariable.Tostring)
param of HTTP request should be
<cfhttpparam type="Body" value="#trim(soap).ToString#" name="FileContent"/>
Sample XML File:
<?xml version="1.0" encoding="utf-8" ?>
<queue>
<txt>d15869d856df1ca3a749d071921f29f8</txt>
<id>d15869d856df1ca3a749d071921f29f8</id>
</queue>
for example in iranfairco.com/getXml getXml get a file xml from external request for example from other site.
now how can send this xml to this url??
From your question i udnerstand its a simple Post or Get to a URL, hence I suppose you could use System.Net's HttpWebRequest and HttpWebResponse classes for posting data, including XML data.
I have a Flex application that needs to grab reporting data from a JasperReports Server, through the JasperReports Server Web Services API. Flex Builder 3 does a nice job of generating the web services consumption code, with one exception. If you ask for a directory list or an accounting of report parameters, JR Server returns plain XML in the SOAP wrapper and Flex parses it just fine. However, if you ask for a report itself, whether in XML or PDF format, it comes back as a multipart MIME message with some descriptive XML as the first part and the report -- even if the report itself is XML -- as the second part. Flex doesn't know what to do with multipart messages and just complains about invalid XML.
Here's a sample of the response. My current strategy is do some string parsing and manage the bits individually. But does Flex have any built-in methods to handle this? (I've been unable to find any.)
------=_Part_2_27050467.1235668849951
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <0F082AF1DAF83B3077B1867B4FC8AAA6>
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:runReportResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://axis2.ws.jasperserver.jaspersoft.com">
<runReportReturn xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?>\n<operationResult version="2.0.1">\n\t<returnCode><![CDATA[0]]></returnCode>\n</operationResult>\n
</runReportReturn>
</ns1:runReportResponse>
</soapenv:Body>
</soapenv:Envelope>
------=_Part_2_27050467.1235668849951
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-Id: <report>
%PDF-1.4\n%âãÏÓ\n1 0 obj <</Filter/FlateDecode/Length 29>>stream\nx+är\ná26S°00S\bIár\rá\näâ
What I am going to say is only what I believe:I may be wrong since I haven't tried this out.
I don't think you have much choice. Flex HTTPService (or whatever you are using) can offer only so many (/or so few) data formats. See here. For any custom stream you will have to retrieve it as an object and pass it through your own decoder. It appears that Flex does not do any parsing of the MIME message but depends on (which is also how browsers behave typically) the server to identify the content that is being transmitted. If the server only sends a text file but changes the content type to say audio/mpeg I think you will have the same problem. Even when Flex does know hot to handle text.
If you ever can get around to doing this experiment (with text files as MIME type video or whatever fancies you) do let us know.
Meanwhile, you can take a look at SerializationFilter and go on and add a new MIME type for PDF!
Hopefully, life will be a little easy with Flex 4 and the HTTPMultiService.