私が持っている非常に単純な (本質的に空/機能のない) サービスを使用して、svcutil.exe でプロキシを生成しようとしています。これが私のサーバーです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
class Server2
{
static void Main(string[] args)
{
Console.WriteLine("Server");
Uri baseAddress = new Uri("http://localhost:1234");
var host = new ServiceHost(typeof(TheContractService), baseAddress);
//host.AddServiceEndpoint(typeof(TheContractService), new WSHttpBinding(), "ContractService");
host.Open();
Console.ReadLine();
}
}
[ServiceContract]
class TheContractService
{
[OperationContract]
void Expose()
{
Console.WriteLine("Exposed");
}
}
[DataContract]
class TheContract
{
[DataMember]
public string PublicProperty { get; set; }
[DataMember]
public string PublicField;
[DataMember]
private string PrivateProperty { get; set; }
[DataMember]
private string PrivateField;
[DataMember (Name = "BetterName")]
private string fudshjguhf;
}
次に、MEX を許可するように .config ファイルをセットアップする必要があります。これが私のサーバー構成です。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ContractService"
behaviorConfiguration="MexServiceBehavior">
<endpoint address="ContractService"
binding="basicHttpBinding"
contract="TheContractService"
/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MexServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
ここで何が間違っていますか?このコマンドを実行しようとすると:
svcutil /t:code http://localhost:1234/mex /out ContractService.cs /config: ContractService.config
400 または 405 エラーが発生し、クライアント プロキシが正常に生成されません。誰かが私が現在持っているものに何か問題を見ることができますか? ありがとう!