使用Visual Studio Web服务器托管WCF SOAP端点时出现问题
本文关键字:端点 SOAP 问题 WCF Studio Visual Web 服务器 使用 | 更新日期: 2023-09-27 18:00:14
我有一个已知的工作web服务,它被配置为SOAP和REST绑定。我可以用测试工具调用它,我可以看到SOAP POST的执行,然后SOAP响应都很好。
然而,当我尝试在视觉工作室2010卡西尼主持服务时,我会得到以下行为:
1) 当将端点调用为REST并使用WebChannelFactory类时,该服务可以工作
2) 当将端点调用为SOAP并使用ChannelFactory类时,服务会抛出一个错误,我得到一个400响应。(错误如下)
3) 当将端点调用为SOAP并使用c#SOAP引用时,服务就可以工作
困惑不?
我想知道这是不是和我使用卡西尼版本的端口号有关?
就在人们开始告诉我在IIS中托管之前,我真的需要在Cassini中完成这项工作,作为WCF 教程的一部分
以下是不起作用的原始HTTP请求(当针对正在工作的IIS部署和有故障的Visual Studio Web服务器调用时)
IIS工作:
POST http://api.dev.videolibraryserver.com/VLSContentService.svc/soap/ HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IVLSContentService/EchoWithGet"
Host: api.dev.videolibraryserver.com
Content-Length: 180
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><EchoWithGet xmlns="http://tempuri.org/"><message>Hello World!</message></EchoWithGet></s:Body></s:Envelope>
视觉工作室(卡西尼)-不工作:
POST http://127.0.0.1:52587/VLSContentService.svc//soap HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IVLSContentService/EchoWithGet"
Host: 127.0.0.1:52587
Content-Length: 180
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><EchoWithGet xmlns="http://tempuri.org/"><message>Hello World!</message></EchoWithGet></s:Body></s:Envelope>
使用卡西尼时的错误响应
HTTP/1.1 400 Bad Request
Server: ASP.NET Development Server/10.0.0.0
Date: Thu, 23 Jun 2011 10:42:09 GMT
Content-Length: 1209
Content-type: text/html;charset=utf-8
Connection: Close
<html>
<head>
<title>Bad Request</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: 8pt;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: 8pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style>
</head>
<body bgcolor="white">
<span><h1>Server Error in '/' Application.<hr width=100% size=1 color=silver></h1>
<h2> <i>HTTP Error 400 - Bad Request.</i> </h2></span>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> ASP.NET Development Server 10.0.0.0
</font>
</body>
</html>
NET异常(尽管不相关,因为服务器没有返回响应)
C:'Users'Peter Heard'Desktop'TestClient'Debug>TestClient.exe "http://ipv4.fiddle
r:52587/VLSContentService.svc/" "Hello World!" 2
***************************
About to call SOAP web service interface TestSOAPUsingChannelFactory()
There was an errorSystem.ServiceModel.ProtocolException: The remote server retur
ned an unexpected response: (400) Bad Request. ---> System.Net.WebException: The
remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
nnelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResp
onse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factor
y, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
nnelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeS
pan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message messag
e, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at IVLSContentService.EchoWithGet(String message)
at TestClient.Program.TestSOAPUsingChannelFactory() in C:'Repositories'VideoL
ibraryServer'trunk'prototypes'Hml_Api_Wcf'TestClient'Program.cs:line 96
at TestClient.Program.Main(String[] args) in C:'Repositories'VideoLibraryServ
er'trunk'prototypes'Hml_Api_Wcf'TestClient'Program.cs:line 47
******更新************
虽然这个问题的答案是正确的。我的测试没有成功。实际上,我试图在IIS和Cassini的url中传递一个"//",但它对Cassini不起作用。显然,IIS在处理引号时更加健壮。下面的评论谈到了这一点,但我想我会更新答案。
"不工作"请求的第一行在URL中有一个额外的斜杠:
POST http://127.0.0.1:52587/VLSContentService.svc//soap HTTP/1.1
^