简体   繁体   English

WCF REST 托管在 IIS 6 中,无法在客户端上使用它

[英]WCF REST hosted in IIS 6 , not able to consume it on client

I have hosted my WCF REST Service in IIS6.我在 IIS6 中托管了我的 WCF REST 服务。 But when I try to consume any method, it gives me an error 400.但是当我尝试使用任何方法时,它会给我一个错误 400。

However when I use the same url in IE, the desired response is achieved.但是,当我在 IE 中使用相同的 url 时,可以实现所需的响应。 How come I can't consume it in my client while I can hit it directly in IE.为什么我不能在我的客户端使用它,而我可以直接在 IE 中点击它。

Following is the Client code:以下是客户端代码:

string xmlInputValue = XMLUtility<string>.GetDataContractXml("Testing", null);

WebClient wc = new WebClient();
wc.Headers["Content-Type"] = "application/octet-stream";
xmlInputValue = string.Empty;
byte[] buf = new byte[0x10000];
wc.UploadString(new Uri(@"http://localhost/FileUpload/UploadData/PingTest/?123"), "POST", "4567");

One quick question, why are you setting Content-type as "application/octet-stream"?一个简单的问题,你为什么将 Content-type 设置为“application/octet-stream”? are you sure service binding is expecting the same content-type.您确定服务绑定期望相同的内容类型。 Anyways, I'd capture Fiddler trace (using fiddler tool: http://fiddler2.com ) for IE (success scenario) and check how request is sent by IE which is accepted by service and compare with request sent by client application.无论如何,我会为 IE 捕获 Fiddler 跟踪(使用 fiddler 工具: http://fiddler2.com )并检查 IE 如何发送请求,该请求被服务接受并与客户端应用程序发送的请求进行比较。

HTH, Amit HTH,阿米特

Got the answer.得到了答案。 While using IIS for hosting the service, endpoint address should be blank使用 IIS 托管服务时,端点地址应为空

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM