我有一个WCF Web服务,我写的工作正常,然后我从另一个应用程序复制了Web服务的内容,并创建了一个新的WCF文件,它创建了一个新的在web.config中,但name属性表示无法找到命名空间。无法在WCF Web服务的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"
不工作,它不能找到它。
我不知道我在做什么错,但我已经在这个上花了很多年了!这第一个正常工作,但它是第二个问题。
实际的错误是:
的“名称”属性无效 - 值Testing.ws.mainGrid.Test根据其数据类型“serviceNameType”是无效的 - 枚举约束失败
如果让intellisense做它的工作,那么它会显示第一个Web服务,但不是我的新服务!
看起来你正在将ASMX(你的类实现)与WCF(你的web.config)混合使用。 –
另外,您正尝试使用'webHttpBinding'作为SOAP服务 - 'webHttpBinding'用于REST。 – Tim