2012-02-08 44 views
0

我正在研究基於soap的wcf服務,它需要接受一個參數,然後進行相應的響應。當我試圖通過測試客戶端使用它時,出現以下錯誤:無法使用基於SOAP的wcf服務

值不能爲空。參數名稱:S

interface:  

[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Xml, 
    ResponseFormat = WebMessageFormat.Json, UriTemplate = "/updateTimesheet?timesheetID={timesheetID}")] 
[OperationContract] 
string updateTimesheet(string timesheetID); 

實現類:

public string updateTimesheet(string timesheet) 
{ 
    XmlDocument doc = new XmlDocument(); 
    doc.LoadXml(timesheet); 
    XmlNode xnodeTimeSheetHourID = doc.DocumentElement.SelectSingleNode("TimeSheetHourID"); 
    XmlNode xnodeHours = doc.DocumentElement.SelectSingleNode("TimeSheetHourID"); 
    return xnodeTimeSheetHourID.Value+" "+xnodeHours.Value; 
} 

的web.config:

<service behaviorConfiguration="postServiceBehavior" name="postService"> 
<endpoint address="http://172.xx.xxx.xxx:xxxx/postService.svc/basic" binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="IpostService"> 
</endpoint> 
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 

可以將某些opne請幫助我如何解決這個錯誤嗎?我敢肯定,有在WebInvoke方法有些問題,但我沒能抓住它

感謝

潘卡

+1

您的代碼意味着您正在使用webHttpBinding,因此updateTimesheet操作將返回一個JSON格式的響應而不是soap。您可以請將您的system.serviceModel配置或WCF服務配置代碼添加到您的答案? – 2012-02-08 14:41:21

+0

您可以發佈客戶端代碼,瞭解您如何訪問WCF服務 – Rajesh 2012-02-08 15:09:59

+0

@SixtoSaez請檢查我的更新代碼,我在此處添加了我的web.config代碼。這是你問的嗎? – pankaj 2012-02-09 09:40:45

回答

0

在web.config文件中的端點定義是錯誤的:

它應該是類似下面:

<service behaviorConfiguration="postServiceBehavior" name="namespace.postService"> 
<endpoint address="http://172.xx.xxx.xxx:xxxx/postService.svc/basic" binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="namespace.IpostService"> 
</endpoint> 
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 

檢查的名稱和合同的服務元素和端點元素各自的屬性LY。

爲了得到正確的一個,如果你可以發佈你的接口類的完整骨架,那麼我可以給你什麼名稱空間的值應該是。