问题描述
||
我有一个已知的工作Web服务,该服务被配置为SOAP和REST绑定。我可以使用测试工具来调用它,并且可以看到SOAP POST即将进行,然后SOAP响应一切正常。
但是,当我尝试在Visual Studio 2010 Cassini中托管该服务时,会出现以下现象:
1)当将端点作为REST调用并使用WebChannelFactory类时,该服务有效。
2)当将端点作为SOAP调用并使用ChannelFactory类时,服务将引发错误,并且得到400响应。 (错误如下)。
3)当将端点作为SOAP调用并使用c#SOAP引用时,该服务有效。
困惑不?
我想知道我是否为Cassini版本使用了端口号吗?
在人们开始告诉我要在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>
视觉工作室(CASSINI)-不起作用:
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>
使用CASSINI时的错误响应
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 @R_81_4045@ion:</b> ASP.NET Development Server 10.0.0.0
</font>
</body>
</html>
.NET EXCEPTION(尽管无关,因为没有从服务器返回响应)
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
^