2011-01-14 40 views
1

我使用SOAP端點配置了傳統的WCF服務。在我的客戶項目中,我添加了服務參考,等等。這些都按預期工作。帶JSON,JSONP和SOAP端點的WCF服務

我創建了一個啓用JSONP的WCF服務,對.svc文件,web配置等進行了修改。我創建了一個測試客戶端頁面進行測試。我成功地調用了JSONP服務。

但是,我對Web配置所做的更改打破了SOAP服務的服務參考。我想要使​​用兩種類型的端點。我不知道如何配置服務和Web配置。

如果HTTP GET只,可每一次操作(如果不管它是用於SOAP或JSONP)與裝飾:[WebGet(ResponseFormat = WebMessageFormat.Json)]

然後我的服務等級需求:[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

現在當我嘗試更新我的服務參考在我的客戶端項目中我得到

已綁定實例已關聯以偵聽URI'http:// flixsit:1000/FlixsitWebServices.svc'。如果兩個端點想要共享相同的ListenUri,則它們也必須共享相同的綁定對象實例。兩個衝突的端點是在AddServiceEndpoint()調用,配置文件或AddServiceEndpoint()和config的組合中指定的。

將SOAP配置添加到我的webconfig中也會中斷JSONP端點。在客戶端調用JSONP不需要客戶端服務引用(或代理生成),但是SOAP可以更正嗎?

我的服務WebConfig:

<system.serviceModel> 
    <behaviors> 
    <endpointBehaviors> 
     <behavior name="webHttpBehavior"> 
     <webHttp /> 
     </behavior> 
    </endpointBehaviors> 
    <serviceBehaviors> 
     <behavior name="DefaultBehaviors">   
     <serviceMetadata httpGetEnabled="true" />   
     <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <bindings> 
    <webHttpBinding> 
     <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" /> 
    </webHttpBinding> 
    <basicHttpBinding> 
     <binding name="BasicHttpEndpointBinding" /> 
    </basicHttpBinding> 
    </bindings> 
    <services> 
    <service name="Flixsit.Services.FlixsitWebServices" behaviorConfiguration="DefaultBehaviors"> 
     <endpoint name="JSONPEndPoint" address="" 
            binding="webHttpBinding" 
            bindingConfiguration="webHttpBindingWithJsonP" 
            contract="Flixsit.Services.IFlixsitWebServices" 
            behaviorConfiguration="webHttpBehavior" /> 
     <endpoint name="HttpEndPoint" address="" 
            binding="basicHttpBinding" 
            contract="Flixsit.Services.IFlixsitWebServices" /> 
     <host> 
     <baseAddresses> 
      <add baseAddress="http://Flixsit:1000/FlixsitWebServices.svc" /> 
     </baseAddresses> 
     </host> 
    </service> 
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
+0

修改您的問題,以便整個配置可見。 – 2011-01-14 07:05:23

回答

0

這個錯誤清楚地說明了問題。你有兩個地址相同但綁定不同的endpoits。不允許。在綁定webHttpBinding的端點中設置address =「jsonp」。您將撥打/ 服務 .svc/jsonp

+0

這樣做並獲得HTTP狀態400.我無法添加服務引用(SOAP)或調用JSONP EndPoint。我從我的.svc文件中刪除了這行:Factory =「System.ServiceModel.Activation.WebServiceHostFactory」,並且能夠添加服務引用 - 但是,JSONP仍然無法工作。感謝您給予的幫助...... – obautista 2011-01-14 13:07:31