0

他のプラットフォーム(具体的にはPHP)にアクセスできるようにしたいnet.tcpサービスがあります。このために、私はhttpバインディングを使用しています。

私はhttpエンドポイントを作成しています:

ServiceHost svh = new ServiceHost(typeof(MyService));
var httpLocation = "http://" + address + ":4041";
svh.AddServiceEndpoint(typeof(IMyService), new WebHttpBinding(WebHttpSecurityMode.None), 
                                   httpLocation);

svh.AddServiceEndpoint(
                    ServiceMetadataBehavior.MexContractName,
                    MetadataExchangeBindings.CreateMexHttpBinding(),
                    httpLocation + "/mex"
                    );

svh.Open();

さて、にアクセスしてブラウザ経由でサービスを探索しようとすると、次のhttp://localhost:4041ようになります。

<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
<Code>
<Value>Sender</Value>
<Subcode>
<Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</Value>
</Subcode>
</Code>
<Reason>
<Text xml:lang="en-US">
The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
</Text>
</Reason>

私は何が間違っているのですか?

4

2 に答える 2

1

ブラウジングするときは.svc.asmx末尾の?wsdl.

localhost:4041/ServiceVirtualDirectory/Service.svc?wsdl
于 2013-01-17T22:43:35.430 に答える
1

アクセスしてみましたhttp://localhost:4041/MyService.svc?wsdlか?

サービスが設計上 REST-ful であるかどうかわからないため、WebHttpBinding を使用しました。サービスが実際に REST-ful である場合、その形式は 次のようhttp://localhost:4041/MyService.svc/MyMethod/MyDataになり、ブラウザーに結果が表示されるはずです。このASP.NET スレッドに基づいて、 WebHttpBehavior.

サービスが REST-ful でない場合はBasicHttpBinding、要件に基づいて (通常の SOAP メッセージを使用する) またはそのいとこを検討する必要があります (このSO スレッドを参照)。

お役に立てれば。

于 2013-01-18T06:11:33.623 に答える