0

Visual Studio 11 を使用してサービスを追加します (サービス参照の追加)。サービス Article を追加すると、コンストラクターが 1 つある articleClient があります。

public RssArticleServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
            base(binding, remoteAddress) {
    }

このコンストラクターを使用するにはどうすればよいですか?どのバインディングの値を使用すればよいかわかりません

例やサンプルをお願いします??

メルシー

よろしくお願いします


私はこれをします:

BasicHttpSecurityMode securitymode = BasicHttpSecurityMode.Transport; BasicHttpBinding binding = new BasicHttpBinding(securitymode); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; Uri uri = new Uri("adresse/RssArticleService.svc";); _clientArticles = new RssArticleServiceClient(binding, new EndpointAddress("adresse/RssArticleService.svc";)); var result=await _clientArticles.GetRssDataAsync("1", "fr");

そして、このエラーを解決します:

**here was no endpoint listening at adresse/RssArticleService.svc that could accept the message. This is often caused by an incorrect address or SOAP**

バインディングのタイプを変更する必要がありますか??

4

1 に答える 1

1

これは私の実装です:

BasicHttpSecurityMode securitymode = HostSource.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;
BasicHttpBinding binding = new BasicHttpBinding(securitymode);
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;

Uri uri = new Uri(Application.Current.Host.Source, "../service.svc");
_client = new RssArticleServiceClient(binding, new EndpointAddress(uri))

編集:これを web.config に追加する必要があります:

<system.serviceModel> 
<services>
  <service name="namespace.RssArticleService"
           behaviorConfiguration="RssArticleServiceBehavior">
    <endpoint address=""
              binding="basicHttpBinding"
              contract="namespace.IRssArticleService"/>
  </service>
</services>
<serviceBehaviors>
   <behavior name="RssArticleServiceBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
   </behavior>
 </serviceBehaviors>
 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
于 2012-09-20T14:30:19.127 に答える