MiniCalcという2つの操作しかない基本的な電卓サービスを作成しました。 AddとMulを実行し、コンソールアプリケーションでそれをホストしました。"Add Service Reference"で自己ホストサービスのプロキシを生成できません
using(ServiceHost host = new ServiceHost(typeof(MiniCalcService.Service),
new Uri("http://localhost:8091/MiniCalcService")))
{
host.AddServiceEndpoint(typeof(MiniCalcService.IService),
new BasicHttpBinding(),
"Service");
host.Open();
Console.Write("Press ENTER key to terminate the MiniCalcHost . . . ");
}
は、それからサービスを消費するコンソールアプリケーションを作成し、プロキシクラスを作成することにより、手動でプロキシを作成し、サービスを呼び出すためのChannelFactoryを作成しました。
EndpointAddress ep = new EndpointAddress("http://localhost:8091/MiniCalcService/Service");
IService proxy = ChannelFactory<IService>.CreateChannel(new BasicHttpBinding(),ep);
私は適切にサービス契約を起動し、期待通りの結果を取得することができました。
今、Add Service Reference
を使用してプロキシを作成しました。
私は私が何をしないか、間違ってやっているサービス参照の追加]ウィンドウ
There was an error downloading 'http://localhost:8091/MiniCalcService/Service'.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: 'http://localhost:8091/MiniCalcService/Service'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:8091/MiniCalcService/Service. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
でGo]をクリックしたときに、私は次のエラーを取得しますか?
ブラウザで.SVCにアクセスすると、それはいくつかの使用方法の例や、あなたのサービスがそれについての情報を提供しないことについて何かを示して? –
.svcファイルはありません。私はService.csとそれに対応するIService.csを作成しました。私の無知を気にしないでください。ただし、.svcファイルが必要です。プロキシを生成してサービスを使用するツールを使用する必要がありますか? – Animesh
尋ねたことがない場合は、無知です。誰もが何も知らない。ある時点ではゼロから始める必要があります。私の答えを見てください。 –