2つの異なるエンドポイントでサービスを公開できます。例えば、SOAP
をサポートするバインディングを使用することができる。 basicHttpBinding
、REST
はwebHttpBinding
を使用できます。私はそのような場合には、次の動作設定で2つのエンドポイントを設定する必要があり、あなたのREST
サービスはJSON
になりますと仮定
<endpointBehaviors>
<behavior name="jsonBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
あなたのシナリオでは、エンドポイント構成の例は、
<services>
<service name="TestService">
<endpoint address="soap" binding="basicHttpBinding" contract="ITestService"/>
<endpoint address="json" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="ITestService"/>
</service>
</services>
が適用されます操作契約に[WebGet]
を入力してRESTfulにします。例えばサービス参照を追加した後のSOAPサービスの
public interface ITestService
{
[OperationContract]
[WebGet]
string HelloWorld(string text)
}
SOAPリクエストクライアントエンドポイントの設定、httpgetenabledがtrueまたはfalseに設定について
<client>
<endpoint address="http://www.example.com/soap" binding="basicHttpBinding"
contract="ITestService" name="BasicHttpBinding_ITestService" />
</client>
C#で
TestServiceClient client = new TestServiceClient();
client.GetAccount("A123");
出典
2016-04-26 06:06:38
VVN
そして、何?私も同様にこれを変更する必要がありますか? – Rakesh