私はそこにWCFを持つSilverlightアプリケーションを持っています。 それは私が私のようなインターフェイスに何か追加する必要があります理解してきたWCFをセルフホストされているので:Silverlight to self hosted WCF
[ServiceContract]
public interface IPolicyRetriever
{
[OperationContract, WebGet(UriTemplate = "/clientaccesspolicy.xml")]
Stream GetSilverlightPolicy();
[OperationContract, WebGet(UriTemplate = "/crossdomain.xml")]
Stream GetFlashPolicy();
}
と実装を:
Stream StringToStream(string result)
{
WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml";
return new MemoryStream(Encoding.UTF8.GetBytes(result));
}
public Stream GetSilverlightPolicy()
{
string result = @"<?xml version=""1.0"" encoding=""utf-8""?>
<access-policy>
<cross-domain-access>
<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>";
return StringToStream(result);
}
public Stream GetFlashPolicy()
{
string result = @"<?xml version=""1.0""?>
<!DOCTYPE cross-domain-policy SYSTEM ""http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"">
<cross-domain-policy>
<allow-access-from domain=""*"" />
</cross-domain-policy>";
return StringToStream(result);
}
が、私は私が持っている、次の手順を理解していませんWCFへのSilverlight呼び出しが連絡例外を発生させないようにするためです。
私は書かなければならないコードをどこに教えてもらえますか? (私がgoogleすると、WCFがclientaccesspolicyを取得するために呼び出されたときに、何を追加する必要があるのかわかりませんでした。私はSilverlightとWCFを初めて使い、なぜexacltyを追加する必要があるのでしょうか?エンドポイント...)
これは私のServiceReference.ClientConfigです:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMapService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:4693/MapService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMapService" contract="MapService.IMapService"
name="BasicHttpBinding_IMapService" />
</client>
</system.serviceModel>
</configuration>
はあなたに感謝!
の範囲で、あなたは私にあなたのサービスを実行例のURLを与えることができますか? (つまり、http://myapp.com/service.svc)?私はより良い答えを得ることができます。何か必要なものを自由に抽象化することができます。ちょうどあなたの解決策を導き出すことができる例です。 –
@Taylor:http:// localhost:4693/MapService.svc – gln
http:// localhost: 4693/clientaccesspolicy.xml何を入手しますか? –