文書化されていない Web サービスがあり、Visual C# で記述されたクライアントを使用して、この Web サービスのバージョンを取得する必要があります。問題は、私が初心者すぎることです。
Visual Studio にサービス リファレンスを追加したので、プロキシ ファイルと output.config ファイルを取得しました。
クラスの新しいインスタンスを開始するために、VS から次の行を取得します。
DentalScannerServiceClient client = new DentalScannerServiceClient();
だから私はこれを私のコンソールアプリに入れました:
DentalScannerServiceClient client = new DentalScannerServiceClient();
client.GetSoftwareVersion();
エラー「メソッド 'GetSoftwareVersion' のオーバーロードは 0 引数を取ります」を取得します。client.GetSoftwareVersion:
Status DentalScannerServiceClient.GetSoftwareVersion( out string version )
だから私はこのコードを試します:
DentalScannerServiceClient client = new DentalScannerServiceClient();
string oo;
client.GetSoftwareVersion(out oo);
次に文字列を出力しますが、コードを実行すると次のエラーが発生します。
"InvalidOperationException was unhandled" "Could not find default endpoint element that references contract 'IDentalScannerService' in the ServiceModel client configuration section. これは、アプリケーションの構成ファイルが見つからなかったか、このコントラクトに一致するエンドポイント要素が見つからなかったためである可能性がありますクライアント要素。」
これを解決する方法、またはどこから探し始めるかについてのアイデアはありますか? どんな助けにも感謝します。多分それは簡単なことです。私もC#の経験はほとんどありません。
app.config:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ThisIsTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><applicationSettings>
<ThisIsTest.Properties.Settings>
<setting name="ThisIsTest_localhost_DentalScannerService" serializeAs="String">
<value>http://localhost:8731/DentalServiceLib/DentalScannerService/</value>
</setting>
</ThisIsTest.Properties.Settings>
</applicationSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicEndPoint" 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:8731/DentalServiceLib/DentalScannerService/"
binding="basicHttpBinding" bindingConfiguration="BasicEndPoint"
contract="Scanner.IDentalScannerService" name="BasicEndPoint" />
</client>
</system.serviceModel>
</configuration>
output.config (これは wsdl.exe から取得し、 [プロジェクト] -> [既存の項目を追加] を実行して追加しました:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicEndPoint" 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:8731/DentalServiceLib/DentalScannerService/"
binding="basicHttpBinding" bindingConfiguration="BasicEndPoint"
contract="IDentalScannerService" name="BasicEndPoint" />
</client>
</system.serviceModel>
</configuration>