views:

1227

answers:

2

I am trying to make a Delphi client (Delphi 2006) to communicate with a service written using WCF. Service is damn simple with just one function. Technically like below:

[ServiceContract (Namespace = "http://www.company.com/sample/")]
public interface IService
{
    [OperationContract]
    string GetNumber (string name);
}

I have hosted this service on IIS and exposed it using basicHttpBinding with mex end point. I am able to use it in .NET clients.

I tried to run WSDLImp.exe and it generated a source code unit (btw, it generates wierd classes to encapsulate string type. Why cant it be same as Delphi string type?). When I try to call this service, I get the exception:

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

I don't see any way to configure the Delphi Win32 client to chanding the binding or security parameters. How can I fix this problem?

+1  A: 

I've had the exact same problem. Delphi just has hard time importing the WSDL exposed by WCF. One solution is to add an ASMX wrapper to your service and use that with Delphi clients.

Here's an example:

[ServiceContract (Namespace = "http://www.company.com/sample/")]
public interface IService
{
    [OperationContract]
    string GetNumber (string name);
}

public class Service : IService
{
    public string GetNumber (string name)
    {
        return Repository.GetNumber(name);
    }
}

[WebService(
    Namespace = "http://www.company.com/sample/",
    Name = "wstest",
    Description = "description")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AsmxService : WebService
{
    [WebMethod]
    public string GetNumber(string name)
    {
        return Repository.GetNumber(name);
    }
}
Darin Dimitrov
Sorry but I don't understand what exactly you mean by "add an ASMX wrapper". Please can you elaborate?
Hemant
By "add an ASMX wrapper" I mean that you could add an ASMX web service to your solution that has the same methods as your WCF service and these methods perform the exact same tasks. Once you add this asmx web service you get an .asmx endpoint which could be used by Delphi clients.
Darin Dimitrov
I wouldn't jump to ASMX anymore: http://johnwsaundersiii.spaces.live.com/blog/cns!600A2BE4A82EA0A6!860.entry.
John Saunders
@John, I wouldn't jump into Delphi neither. But as you can see there are still people using it (including me) and we have to find solutions to integrate it with newer technology (WCF). I proposed ASMX because it is something I've tested myself and proved working quite nice in production.
Darin Dimitrov
I tried what darin suggested and indeed, Delphi seems to integrate with asmx service pretty nicely. It has been pretty smooth.
Hemant
+1  A: 

You need to look at the network traffic between the client and service to see what's going on. Alternatively, turn on WCF tracing on the service, possibly including message tracing. You should be able to see what's going on, in great detail.

John Saunders