不能使用基于肥皂的wcf服务

时间:2012-02-08 14:34:05

标签: wcf post 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方法存在一些问题,但我无法理解它

由于

的Pankaj

1 个答案:

答案 0 :(得分: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" />

分别检查service元素和endpoint元素中的name和contract属性。

如果你可以发布你的接口类的完整骨架,为了得到合适的一个,那么我可以给你命名空间的值应该是什么。

相关问题