我编写了一个运行良好的 WCF Web 服务,然后我从另一个应用程序复制了该 Web 服务的内容,并创建了一个新的 WCF 文件,该文件在 web.config 中创建了一个新文件,但名称属性显示找不到命名空间。
以下是我的 WCF 前几行的示例:
namespace Testing.ws.mainGrid
{
[WebService(Namespace = "")]
[ScriptService]
[ToolboxItem(false)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Test : WebService
{
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
[WebMethod]
public void GetRecords()
{
((NameValueCollection)new WebClient().Headers).Add("accept", "text/xml");
string str1 = "1";
string str2 = "1";
string str3 = "1";
这是我的 web.config:
<system.serviceModel>
<services>
<service name="Testing.ws.getStaffTree">
<endpoint address="" behaviorConfiguration="Testing.ws.getStaffTreeAspNetAjaxBehavior"
binding="webHttpBinding" contract="Testing.ws.getStaffTree" />
</service>
<service name="Testing.ws.mainGrid.Test">
<endpoint address="" behaviorConfiguration="Testing.ws.mainGridAspNetAjaxBehavior"
binding="webHttpBinding" contract="Testing.ws.mainGrid" />
</service>
</services>
基本上name="Testing.ws.mainGrid.Test"
不起作用并且找不到它。
我不知道我做错了什么,但我已经在这上面花了很长时间了!第一个工作正常,但第二个有问题。
实际错误是:
“name”属性无效 - 根据其数据类型“serviceNameType”,Testing.ws.mainGrid.Test 值无效 - 枚举约束失败
如果您让智能感知完成其工作,那么它会显示第一个 Web 服务,但不会显示我的新服务!
我认为你的第二项服务应该如下。注意合约名称的变化:
<service name="Testing.ws.mainGrid.Test">
<endpoint address="" behaviorConfiguration="Testing.ws.mainGridAspNetAjaxBehavior"
binding="webHttpBinding" contract="Testing.ws.mainGrid.Test" />
</service>
之前它指向命名空间,而不是类类型。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)