我有一個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