2011-06-23 93 views
2

我有一個已知的工作Web服務,它被配置爲SOAP和REST綁定。我可以用測試工具調用它,我可以看到SOAP POST的進行,然後SOAP響應都很好。在使用Visual Studio Web服務器託管WCF SOAP端點時遇到問題

但是當我嘗試在Visual Studio 2010中承載服務卡西尼我得到以下行爲:

1)當主叫端爲REST和使用WebChannelFactory類的服務工作。
2)當將端點作爲SOAP調用並使用ChannelFactory類時,服務拋出一個錯誤,我得到一個400響應。 (錯誤在下面)。
3)當將端點作爲SOAP調用並使用c#SOAP引用時,該服務起作用。

令人困惑不?

我想知道這是否與我使用卡西尼版本的端口號有關?


之前人們開始告訴我在IIS來承載我真的需要在卡西尼這個工作作爲教程的一部分對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> 

VISUAL STUDIO(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> 

錯誤響應WHEN USING 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 Information:</b>&nbsp;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在處理引號時更加健壯。下面的評論談論這個,但我想我會更新答案。

+0

我是真的想幫助。我以前走過這條路。很抱歉,如果它出現傲慢。 –

+0

Fairought隊友我很欣賞Ive在過去的幾天裏一直是'MVC問題機器',但是Im是唯一在這裏總是被卡住的開發者,現在似乎總是擁有它。我試着寫一篇關於使用調試器來查看發生了什麼的教程。我也回答了一些問題。乾杯。 – Exitos

回答

1

你的「不工作」要求的第一行的URL額外的斜線:

POST http://127.0.0.1:52587/VLSContentService.svc//soap HTTP/1.1 
               ^
+0

你的權利!看不到樹林。是完全相同的代碼和我放在測試工具中的網址是相同的,不知道爲什麼請求將額外的斜線將發現。猜測我習慣在調試器中查看雙斜槓。謝謝!!! :-) – Exitos

+0

這真的很奇怪,但我改變了IIS一個雙引號,令人驚訝的是它仍然有效。我認爲IIS可以處理雙斜線,卡西尼不能。 – Exitos

+0

這很有趣。我不確切知道HTTP規範說的是什麼(也許雙斜槓實際上是可以接受的),但我的猜測是IIS團隊決定繼續並接受一些無效的請求,而不需要額外的努力在卡西尼。 – Aaron