2012-07-27 11 views
7

मुझे डब्ल्यूसीएफ कॉन्फ़िगरेशन की समस्याएं हैं। मेरे पास एक डब्ल्यूसीएफ वेबसाइट है जो मैं जीईटी पैरामीटर (और अंततः PHP में simplexml_load_file() के साथ एक वेब ब्राउज़र के माध्यम से पहुंचने में सक्षम होना चाहता हूं)। मेरा विजुअल स्टूडियो सॉल्यूशन एक डब्ल्यूसीएफ सेवा लाइब्रेरी प्रोजेक्ट के रूप में स्थापित किया गया है जिसमें इंटरफ़ेस (जहां सेवा परिभाषित की गई है), एक कक्षा (जहां सेवा लागू की गई है, और एक ऐप.कॉन्फिग (जो डिफ़ॉल्ट रूप से वहां था)। मेरे पास एक भी है ।डब्ल्यूसीएफ कॉन्फ़िगरेशन पताफिल्टर मिस्चैच

using System; 
using System.Collections.Generic; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using RTXEngineLib.externalLibrary; 
namespace RTXEngineLib { 
    [ServiceContract(Name = "RTXEngine", Namespace = "")] 
    public interface IRTXEngine { 
     [OperationContract(Name = "GetCountryList"), WebGet(UriTemplate = "/GetCountryList/", ResponseFormat = WebMessageFormat.Xml)] 
     List<Country> GetCountryList(); 
     [OperationContract(Name = "GetRegions"), WebGet(UriTemplate = "/GetRegions/?countryID={countryID}", ResponseFormat = WebMessageFormat.Xml)] 
     List<Region> GetRegions(int countryID); 
     [OperationContract(Name = "GetExchangeAvailability"), WebGet(UriTemplate = "/GetExchangeAvailability/?countryID={countryID}&month={month}&year={year}&regionID={regionID}&resortID={resortID}", ResponseFormat = WebMessageFormat.Xml)] 
     AvailabilityList GetExchangeAvailability(int countryID, String month, int year, String regionID = "?", String resortID = ""); 
     [OperationContract(Name = "GetResortsForDate"), WebGet(UriTemplate = "/GetResortsForDate/?month={month}&year={year}", ResponseFormat = WebMessageFormat.Xml)] 
     List<AvailabilityList> GetResortsForDate(String month, int year); 
     [OperationContract(Name = "GetRegionLists"), WebGet(UriTemplate = "/GetRegionLists/", ResponseFormat = WebMessageFormat.Xml)] 
     List<RegionList> GetRegionLists(); 
     [OperationContract(Name = "GetRegionListCacheState"), WebGet(UriTemplate = "/GetRegionListCacheState/", ResponseFormat = WebMessageFormat.Xml)] 
     Boolean GetRegionListCacheState(); 
    } 
    [DataContract(Namespace = "")] 
    public class LoginRequestResponse { 
     [DataMember] 
     public Boolean Success { get; set; } 
     [DataMember] 
     public AccountStanding AccountStanding { get; set; } 
     [DataMember] 
     public double FTXBalance { get; set; } 
     [DataMember] 
     public List<User> Users { get; set; } 
     [DataMember] 
     public List<ContractData> Contracts { get; set; } 
    } 
    [DataContract(Namespace = "")] 
    public enum AccountType { 
     [DataMember] 
     NonAuthenticatedAccount, 
     [DataMember] 
     AC, 
     [DataMember] 
     PT, 
     [DataMember] 
     Wks 
    } 
    [DataContract(Namespace = "")] 
    public enum AccountStanding { 
     [DataMember] 
     NotAuthenticated, 
     [DataMember] 
     Good, 
     [DataMember] 
     Mixed, 
     [DataMember] 
     Delinquent 
    } 
    [DataContract(Namespace = "")] 
    public struct RegionList { 
     [DataMember] 
     public String CountryName { get; set; } 
     [DataMember] 
     public String CountryID { get; set; } 
     [DataMember] 
     public List<Region> Regions { get; set; } 
    } 
    [DataContract(Namespace = "")] 
    public struct Country { 
     [DataMember] 
     public String CountryName { get; set; } 
     [DataMember] 
     public String ID { get; set; } 
    } 
    [DataContract(Namespace = "")] 
    public struct Region { 
     [DataMember] 
     public String RegionName { get; set; } 
     [DataMember] 
     public String ID { get; set; } 
    } 
    [DataContract(Namespace = "")] 
    public struct User { 
     [DataMember] 
     public String FirstName { get; set; } 
     [DataMember] 
     public String LastName { get; set; } 
     [DataMember] 
     public String Address { get; set; } 
     [DataMember] 
     public String City { get; set; } 
     [DataMember] 
     public String State { get; set; } 
     [DataMember] 
     public String Zip { get; set; } 
     [DataMember] 
     public String CountryOfResidence { get; set; } 
     [DataMember] 
     public String PhoneNumber { get; set; } 
    } 
    [DataContract(Namespace = "")] 
    public struct ContractData { 
     [DataMember] 
     public String ContractID { get; set; } 
     [DataMember] 
     public AccountType AccountType { get; set; } 
     [DataMember] 
     public AccountStanding AccountStanding { get; set; } 
     [DataMember] 
     public String AvailablePoints { get; set; } 
     [DataMember] 
     public String UnavailablePoints { get; set; } 
     [DataMember] 
     public String Usage { get; set; } 
    } 
    [DataContract(Namespace = "")] 
    public struct PointsData { 
     [DataMember] 
     public String ContractID { get; set; } 
    } 
    [DataContract(Namespace = "")] 
    public class GlobalAppCache { 
     [DataMember] 
     public static DateTime RegionListsLastUpdate { get; set; } 
     [DataMember] 
     public static List<RegionList> CachedRegionLists { get; set; } 
    } 
} 

और पुस्तकालय के लिए मेरे App.config इस तरह दिखता है: WCF सेवा परियोजना है जो एक .svc फ़ाइल (जो मेरी कक्षा की ओर इशारा करता है) और एक web.config शामिल मेरी सेवा इंटरफ़ेस इस तरह बनाया गया है

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5555555555555555"> 
     <section name="RTXEngineLib.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> 
    </sectionGroup> 
    </configSections> 
    <system.web> 
    <compilation debug="true"/> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service name="RTXEngineLib.RTXEngineLib"> 
     <endpoint address="" binding="wsHttpBinding" contract="RTXEngineLib.IRTXEngineLib"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/RTXEngineLib/RTXEngineLib/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="True"/> 
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true. Set to false before deployment 
      to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="False"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
    <applicationSettings> 
    <RTXEngineLib.Properties.Settings> 
     <setting name="RTXEngineLib_externalLibrary" serializeAs="String"> 
     <value>http://externalLibrary.com/websvcs/externalLibrary.asmx</value> 
     </setting> 
    </RTXEngineLib.Properties.Settings> 
    </applicationSettings> 
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> 

और फिर मेरी Web.config इस प्रकार है के रूप में:

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <webHttpBinding> 
     <binding name="Web" sendTimeout="00:03:00" maxBufferSize="131072" 
      maxReceivedMessageSize="131072" /> 
     </webHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="Basic" name="RTXEngineLib.RTXEngineLib"> 
     <endpoint address="http://devrtxengine.telemark/RTXService.svc" 
      binding="webHttpBinding" bindingConfiguration="Web" name="Basic" 
      contract="RTXEngineLib.IRTXEngine" listenUri="http://devrtxengine.myserver/RTXService.svc" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     <behavior name="Basic"> 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
     <behavior name="Web"> 
      <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding" 
      httpGetBindingConfiguration="" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

जब मैं http://devrtxengine.myserver/RTXService.svc/GetCountryList मैं निम्न त्रुटि के साथ अंत का उपयोग कर मेरी सेवा को चलाने के लिए प्रयास:

<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> 
<Code> 
<Value>Sender</Value> 
<Subcode> 
<Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:DestinationUnreachable</Value> 
</Subcode> 
</Code> 
<Reason> 
<Text xml:lang="en-US"> 
The message with To 'http://devrtxengine.telemark/RTXService.svc/GetCountryList' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. 
</Text> 
</Reason> 
</Fault> 

मुझे लगता है मेरी App.config और मेरे Web.config के बीच बेमेल किसी तरह का है कि वहाँ है, लेकिन हर समय मैं अपने web.config में कुछ बदलने की कोशिश करता हूं, मैंने अपनी सेवा को तोड़ दिया है इससे पहले कि यह पहले से ही टूटा हुआ है। क्या डब्ल्यूसीएफ अनुभव वाले किसी को कोई सलाह है?

+0

सेवा पुस्तकालय के लिए app.config अप्रासंगिक है - यह उपयोग नहीं किया जाएगा। WCF सेवा के लिए Web.config कॉन्फ़िगरेशन फ़ाइल है जिसका उपयोग आपकी लाइब्रेरी द्वारा किया जाएगा। आप सेवा कैसे कॉल कर रहे हैं? क्या आपके पास एक अलग ग्राहक है, क्या आप एक परीक्षण उपकरण आदि का उपयोग कर रहे हैं? – Tim

+0

मैं इसे अपने वेब ब्राउजर में यूआरएल टाइप करके कॉल कर रहा हूं (जैसा कि मुझे पूर्ण होने पर काम करने में सक्षम सेवा की आवश्यकता है), जैसा कि त्रुटि संदेश से पहले छोटे पैराग्राफ में दिखाया गया है। 'http: // devrtxengine.myserver/RTXService.svc/GetCountryList' –

+1

मैंने देखा कि एंडपॉइंट एड्रेस devrtxengine.telemark था, लेकिन आपके पास listenUri devrtxengine.myserver के रूप में है। सुनिश्चित नहीं है कि यह एक टाइपो है या यदि इससे कोई फर्क पड़ता है। साथ ही, आप व्यवहार के लिए WebHttp बाइंडिंग जोड़ने का प्रयास कर सकते हैं - देखें [डब्ल्यूसीएफ एड्रेसफिल्टर मिस्चैच में कॉन्फ़िगरेशन त्रुटि को हल करना] (http://stackoverflow.com/questions/339421/resolving-configuration-error-in-wcf-addressfilter-mismatch) के लिए एक उदाहरण। – Tim

उत्तर

3

मैंने देखा कि एंडपॉइंट एड्रेस devrtxengine.telemark था, लेकिन आपके पास artrtx ​​devinexengine.myserver के रूप में है। सुनिश्चित नहीं है कि यह एक टाइपो है या यदि इससे कोई फर्क पड़ता है। साथ ही, आप व्यवहार के लिए WebHttp बाइंडिंग जोड़ने का प्रयास कर सकते हैं - उदाहरण के लिए Resolving Configuration Error in WCF AddressFilter Mismatch देखें।

2

यहाँ मैं क्या जाँच जब मुझे लगता है कि त्रुटि प्राप्त है:

* endpoint is missing in web.config, 
* doublecheck the UriTemplate path 
* make sure to set an endpointBehavior inside behaviors, such as 
    <endpointBehaviors> 
    < behavior name =" web" > 
     < webHttp /> 
    </ behavior > 
    </ endpointBehaviors > 
* and set behaviorConfiguration="web" on endpoint your individual endpoint 
+0

मदद करने में खुशी! :-) –

+0

धन्यवाद, दान! मुझे कई स्टैक ओवरफ्लो और Google खोज परिणामों के माध्यम से परेशान होना पड़ा, लेकिन थोड़ी देर के लिए मेरे वेब.कॉन्फिग के w/कई नोड्स/विशेषताओं को झुकाव के बाद आपके संपादन सुझाव थे जो मेरे डब्ल्यूसीएफ काम कर रहे थे। धन्यवाद! –

+0

मुझे खुशी है कि आप इसे काम करने में सक्षम थे। चीयर्स! –

संबंधित मुद्दे