0

I've got a net.tcp service, which I want to make accessible to other platforms (specifically, PHP). For this, I'm using http binding.

I'm creating a http endpoint with:

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();

Now, when I'm trying to explore the service via browser by going to http://localhost:4041, I'm getting:

<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>

What am I doing wrong?

Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224

2 Answers2

1

When browsing, make sure to include the full path to the .svc or .asmx along with a trailing ?wsdl.

localhost:4041/ServiceVirtualDirectory/Service.svc?wsdl
alan
  • 6,705
  • 9
  • 40
  • 70
  • What would be that path in my case? I've tried accessing `http://localhost:4041/Service.svc?wsdl` without any success. I'm not really sure what Service.svc is and where I should take it from – Arsen Zahray Jan 17 '13 at 22:46
  • It's hard to tell, do you host in IIS? Usually the first slash is the name of the virtual directory where the second is the name of the WCF project. – alan Jan 17 '13 at 22:54
1

Have you tried accessing http://localhost:4041/MyService.svc?wsdl?

Not sure if your service is REST-ful by design and that's why you used WebHttpBinding. If your service is actually REST-ful, its format would be http://localhost:4041/MyService.svc/MyMethod/MyData and you should see the results on the browser. Based on this ASP.NET thread, you would need to attach a WebHttpBehavior.

If your serivce isn't REST-ful, you should consider BasicHttpBinding (uses regular SOAP messages) or its cousins based on your requirements (see this SO thread).

Hope this helps.

Community
  • 1
  • 1
Channs
  • 2,091
  • 1
  • 15
  • 20