0

私の単純な wcf は正しく実行されます。これは、wcf にアプリケーションを作成しようとすると期待されるデータが返されるためですが、wcf サービス実行の外でアプリケーションを実行しようとするとエラーが発生するためです。

ここに画像の説明を入力

この問題を解決するにはどうすればよいですか?

wcf サービスの Web 構成

    <?xml version="1.0"?>
        <configuration>

          <system.web>
            <compilation debug="true" targetFramework="4.0" />
          </system.web>
          <system.serviceModel>
<services>
      <service name="WcfService1.Service1">
        <endpoint address="http://192.168.21.102:4424/Service1.svc"
                  binding="wsHttpBinding"
                  contract="WcfService1.IService1"></endpoint>
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"></endpoint>
      </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> 
            <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
          </system.serviceModel>
         <system.webServer>
            <modules runAllManagedModulesForAllRequests="true"/>
          </system.webServer>

        </configuration>

クライアント アプリの構成

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:4424/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
                name="BasicHttpBinding_IService1" />
        </client>
    </system.serviceModel>
</configuration>

私は\nそれらのものに触れたり編集したりしませんでした

4

1 に答える 1

1

2つのこと:

まず、サービスは を使用するように定義されてwsHttpBindingいますが、クライアントは を使用していますbasicHttpBinding。バインディングは一致する必要があります。

次に、クライアント構成のアドレスがに設定されてlocalhostいます。これは、クライアントが同じマシン上でサービスを探していることを意味します。

たとえば、サービスが MySever1 という名前のマシン上にあり (たとえば)、クライアント (ポストされた構成を使用) を MyClient1 という名前のマシンに配置した場合 (これもまた、たとえば)、MyClient1 でサービスを検索します (クライアントの場合は localhost)。

クライアント エンドポイントを に変更するhttp://192.168.21.102:4424/Service1.svcと、ファイアウォールの問題がなければ接続できるはずです。

例えば:

<client>
  <endpoint address="http://192.168.21.102:4424/Service1.svc" 
            binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IService1" 
            contract="ServiceReference1.IService1"
            name="BasicHttpBinding_IService1" />
</client>

編集

サービス側の構成で、エンドポイントに対して次の操作を行います。

service name="WcfService1.Service1">
    <endpoint address=""
              binding="basicHttpBinding"
              contract="WcfService1.IService1">
    </endpoint>
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange">
    </endpoint>
  </service>

クライアント構成で:

<client>
  <endpoint address="http://192.168.21.102:4424/Service1.svc"
            binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IService1" 
            contract="ServiceReference1.IService1"
            name="BasicHttpBinding_IService1" />
</client>

サービス エンドポイント宣言では、address属性が空白であることに注意してください。実際のアドレスを決定するために *.svc ファイルの場所が使用されます。basicHttpBinding次に、クライアントが呼び出すものと一致するようにバインディングを変更します。

クライアント構成で、呼び出しているサービスの完全なアドレスを指定します。

于 2013-05-02T04:44:41.237 に答える