0

私は wcf アプリケーションを作成しました: このコントラクト:

namespace WcfServiceLibrary1
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData(int value);   

    }
}

これはサービスです:

namespace WcfServiceLibrary1
{

    public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
}
}

これは App.config です

  <?xml version="1.0"?>

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2097151"
    useFullyQualifiedRedirectUrl="true"
    executionTimeout="144000"   />
  </system.web>
  <system.serviceModel>
    <!--<bindings>
      <basicHttpBinding>
        <binding name="FileTransferServicesBinding" transferMode="Streamed" messageEncoding="Mtom" maxReceivedMessageSize="2000000">
        </binding>
      </basicHttpBinding>
    </bindings>-->

    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IChatService" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" 
                 sendTimeout="00:03:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
                 maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600" messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true">
          <readerQuotas maxDepth="104857600" maxStringContentLength="104857600" maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600"/>
          <reliableSession ordered="true" inactivityTimeout="00:10:00"/>
          <security mode="None">
            <message clientCredentialType="None" negotiateServiceCredential="false" algorithmSuite="Default"/>
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <services>
      <!--<service behaviorConfiguration="MyServiceTypeBehaviors" name="FileService.FileTransferService">
        <endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="FileTransferServicesBinding" contract="FileService.IFileTransferService"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/FileTranfer"/>
          </baseAddresses>
        </host>
      </service>-->
      <service behaviorConfiguration="MyServiceTypeBehaviors" name="WcfServiceLibrary1.Service1">
        <endpoint address="mex" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IChatService" contract="WcfServiceLibrary1.IService1"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://117.5.36.172:23000/FileTranfer"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

アドレスにサービス参照を追加した後: "http://117.5.36.172:23000/FileTranfer" サービスを正常に実行します。作成後:

ServiceReference1.Service1Client クライアント = 新しい ServiceReference1.Service1Client();

                Console.WriteLine(client.State); ====> return Created
                Console.WriteLine(client.GetData(5)); ==>Not return value, seems 

アクセスではありません。ファイアウォール ポート 23000 を開き、転送ポート ルーターを追加します。私を助けてください

4

1 に答える 1