我有一个我编写的WCF Web服务工作正常,然后我从另一个应用程序复制了Web服务的内容并创建了一个新的WCF文件,该文件在web.config中创建了一个新文件,但name属性表示无法找到命名空间.
以下是我的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";
Run Code Online (Sandbox Code Playgroud)
这是我的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>
Run Code Online (Sandbox Code Playgroud)
基本上name="Testing.ws.mainGrid.Test"不起作用,它找不到它.
我不确定我做错了什么,但我花了很多年的时间!这第一个工作正常,但第二个问题.
实际错误是:
'name'属性无效 - 值Testing.ws.mainGrid.Test根据其数据类型'serviceNameType'无效 - 枚举约束失败
如果让intellisense完成其工作,那么它会显示第一个Web服务,但不会显示我的新服务!
我想你的第二项服务如下.请注意合同名称的变更:
<service name="Testing.ws.mainGrid.Test">
<endpoint address="" behaviorConfiguration="Testing.ws.mainGridAspNetAjaxBehavior"
binding="webHttpBinding" contract="Testing.ws.mainGrid.Test" />
</service>
Run Code Online (Sandbox Code Playgroud)
在它指向命名空间之前,而不是类类型.
| 归档时间: |
|
| 查看次数: |
22910 次 |
| 最近记录: |