콘솔 응용 프로그램에서 호스팅되는 WCF 서비스가 있습니다.클라이언트 액세스 정책 파일에 액세스하지 못했기 때문에 CommunicationException이 발생했습니다.
나는 소켓에 액세스<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior name="CAVES.Framework.Network.IntegrationSuite.IntegrationServices.IntegrationServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="CrossDomainServiceBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="CAVES.Framework.Network.IntegrationSuite.IntegrationServices.IntegrationServiceBehavior"
name="CAVES.Framework.Network.IntegrationSuite.IntegrationServices.IntegrationService">
<endpoint address="" binding="basicHttpBinding" contract="CAVES.Framework.Network.IntegrationSuite.IntegrationServices.Interfaces.IIntegrationService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/IntegrationService" />
</baseAddresses>
</host>
</service>
<service name="CAVES.Framework.Network.IntegrationSuite.IntegrationServices.CrossDomainService">
<host>
<baseAddresses>
<add baseAddress="http://localhost" />
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" contract=
"CAVES.Framework.Network.IntegrationSuite.IntegrationServices.Interfaces.ICrossDomainService" behaviorConfiguration="CrossDomainServiceBehavior"/>
</service>
</services>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
, 클라이언트 액세스 정책이 올바르게 페치하지만 난 IntegrationService의 메소드를 호출하려고 할 때 그것이 나에게 다음과 같은 예외를 제공합니다 :
를다음은 app.config 파일입니다
에 URI를 요청할 때 오류가 발생했습니다. 'http : // localhost : 8731/IntegrationService'. 올바른 도메인 간 정책이 이 아니거나 인 SOAP 서비스에 적합하지 않은 정책을 사용하여 교차 도메인 방식으로 서비스에 액세스하려고 시도했을 수 있습니다. 은 도메인 간 정책 파일을 게시하고 SOAP 관련 HTTP 헤더를 보낼 수 있도록 서비스의 소유자에게 문의해야합니다. InternalsVisibleToAttribute 특성을 사용하지 않고 웹 서비스 프록시에서 내부 형식을 사용하면이 오류가 발생할 수도 있습니다. 자세한 내용은 내부 예외를 참조하십시오.
내부 예외 :
이
{System.Security.SecurityException ---> System.Security.SecurityException : 보안 오류. 에 System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse (IAsyncResult asyncResult)를 입력합니다. System.Net.Browser.BrowserHttpWebRequest. <> c_ DisplayClass5.b _4 (대상 sendState) : System.Net.Browser.AsyncHelper. 에서 <> C_ DisplayClass4.b _1 (sendState 개체) --- System.Net.Browser.AsyncHelper.BeginOnUI에서 내측 예외 스택 추적 --- 끝 (SendOrPostCallback beginMethod은 객체 상태) System.Net System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse에서 .Browser.BrowserHttpWebRequest.EndGetResponse (IAsyncResult를 asyncResult) (IAsyncResult를 결과)}
내 클라이언트 액세스 정책 파일이 잘 보이는 작동해야하고 왜 그런지 모르겠습니다. 나는 소켓에 액세스
<?xml version="1.0" encoding ="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*" />
</allow-from>
<grant-to>
<socket-resource port="4502-4534" protocol="tcp" />
</grant-to>
</policy>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
그래서 포트가 소켓에만 사용된다는 것은 중요하지 않습니까? 나는 정책이 다르다고 믿었다. 내 정책 파일은 루트에있는 서비스와 함께 제공됩니다. 하지만 같은 항구에 있지는 않습니다. 흠. 포인트가 찍혔는지 확인합니다. –
두 웹 서비스 모두에 포트 80을 사용했고 이제는 작동합니다. 결론 : ** 서비스의 포트 **와 동일한 포트에서 항상 clientaccesspolicy.xml을 제공하십시오 (소켓의 경우 항상 http에서 80, tcp에서 943). –