WCF 구성 주소 필터 불일치
-
12-12-2019 - |
문제
WCF 구성 비애를 사용하고 있습니다. GET 매개 변수를 사용하여 웹 브라우저를 통해 액세스 할 수 있기를 원하는 WCF WebService가 있습니다 (및 SimpleXML_Load_file이있는 PHP에서 PHP에서). My Visual Studio 솔루션은 인터페이스 (서비스가 정의 된 위치), 클래스 (서비스가 구현되는 위치 및 app.config)가 포함 된 WCF 서비스 라이브러리 프로젝트로 설정됩니다. 나는 또한 또한 .svc 파일 (내 클래스를 가리키는)과 web.config가 포함 된 WCF 서비스 프로젝트. 내 서비스 인터페이스는 다음과 같이 설계되었습니다 :
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}®ionID={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는 다음과 같습니다.
<?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와 my web.config 사이에 일종의 일종이 일치하지만, 내 web.config에서 무언가를 바꾸려고 할 때마다 나는 그것이 이미 망가진 것보다 더 많은 것을 깰 수 있습니다. 더 많은 WCF 경험을 가진 사람은 어떤 조언이 있습니까?
해결책
엔드 포인트 주소는 devrtxengine.telemark 였지만 ListenURI는 devrtxengine.myserver로 사용됩니다.그것이 오타가 있는지 아니면 그 차이가 있는지 확실하지 않습니다.또한 WebHttpBinding을 비헤이비어에 추가 할 수 있습니다. WCF에서 구성 오류 해결AddressFilter Mismatch 예를 들어
다른 팁
여기에 해당 오류가 발생했을 때 확인하는 것입니다.
* 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
.