Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 300835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:57:02+00:00 2026-05-12T06:57:02+00:00

I’ve written a fairly simple little C# web service, hosted from a standalone EXE

  • 0

I’ve written a fairly simple little C# web service, hosted from a standalone EXE via WCF. The code – somewhat simplified – looks like this:

namespace VMProvisionEXE
{
class EXEWrapper
{
    static void Main(string[] args)
    {
        WSHttpBinding myBinding = new WSHttpBinding();
        myBinding.Security.Mode = SecurityMode.None;

        Uri baseAddress = new Uri("http://bernard3:8000/VMWareProvisioning/Service");
        ServiceHost selfHost = new ServiceHost(typeof(VMPService), baseAddress);

        try
        {
            selfHost.AddServiceEndpoint(typeof(IVMProvisionCore), myBinding, "CoreServices");

            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy12;
            selfHost.Description.Behaviors.Add(smb);

            // Add MEX endpoint
            selfHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

            selfHost.Open();
            Console.WriteLine("The service is ready.");
            Console.ReadLine();

The rest of the C# code; the class VMPService above implements VMProvisionCore.IVMProvisionCore.

namespace VMProvisionCore
{
[ServiceContract(Namespace = "http://Cisco.VMProvision.Core", ProtectionLevel = System.Net.Security.ProtectionLevel.None)]
public interface IVMProvisionCore
{
    [OperationContract]
    bool AuthenticateUser(string username, string password);
}

I can easily create a Visual Studio 2008 client application that consumes this service. No problems. But using Delphi 2007 is a different issue. I can use the WSDL importer in Delphi to retrieve the WSDL from (in this case) http://bernard3:8000/VMWareProvisioning/Service?wsdl The import unit compiles just fine. I have to initialize the proxy by hand since the WSDL doesn’t contain a URL (notice the extra “/CoreServices” as shown in the C# code):

var
  Auth: AuthenticateUser;
  AuthResponse: AuthenticateUserResponse;
  CoreI: IVMProvisionCore;
begin
  CoreI:= GetIVMProvisionCore(False, 'http://bernard3:8000/VMWareProvisioning/Service/CoreServices');
  Auth:= AuthenticateUser.Create;
  try
    Auth.username:= 'test';
    Auth.password:= 'test';
    AuthResponse:= CoreI.AuthenticateUser(Auth);
  finally
    FreeAndNIL(Auth);
  end;

The above code will generate an error when it hits the “CoreI.AuthenticateUser(Auth);”. The error is “Cannot process the message because the content type ‘text/xml; charset=”utf-8″ was not the expected type ‘application/soap+xml; charset=utf-8.“

I suspect that I’ve got a stupid little error somewhere, perhaps during the import of the WSDL or in the connection options or something. Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:57:02+00:00Added an answer on May 12, 2026 at 6:57 am

    Found the solution. It’s multiple parts and requires a few changes to the C# side, more to the Delphi side. Note that this was tested with Delphi 2007 and Visual Studio 2008.

    C# side:
    Use BasicHttpBinding rather than WSHttpBinding.

    Fix Step 1

    BasicHttpBinding myBinding = new BasicHttpBinding();
    myBinding.Security.Mode = BasicHttpSecurityMode.None;
    

    This change will resolve the application/soap+xml errors on the Delphi side.

    Delphi 2007 side:
    Running against the modified C# web service will now generate errors like this:

    Exception class ERemotableException
    with message ‘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).’

    To resolve this problem, add SOAPActions to all your supported interfaces. Here’s the example from my code; this must be done AFTER all of the InvRegistry changes made by the import-from-WSDL-PAS-file’s initialization section:

    Fix Step 2

    InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IVMProvisionCore), 'http://Cisco.VMProvision.Core/CoreServices/%operationName%');
    

    The type name and URL should be obtainable from the Delphi generated import file from the WSDL and/or an inspection of the actual WSDL. The above example was for my own project. After these code changes, then you’ll the error:

    Exception class ERemotableException
    with message ‘The formatter threw an
    exception while trying to deserialize
    the message: Error in deserializing
    body of request message for
    operation….

    This error is resolved by adding the following code (credits to http://www.bobswart.nl/weblog/Blog.aspx?RootId=5:798). Again, this new code must be after all the InvRegistry stuff in the initialization of the WSDL-to-PAS file.

    Fix Step 3

    InvRegistry.RegisterInvokeOptions(TypeInfo(IVMProvisionCore), ioDocument);
    

    At this point, packets will go back and forth between Delphi and C# – but parameters won’t work properly. The C# will receive all parameters as nulls and Delphi doesn’t seem to be receiving response parameters properly. The final code step is to use a slightly customized THTTPRIO object that will allow for literal parameters. The trick to this part is to make sure that the option is applied AFTER the interface has been obtained; doing it before won’t work. Here’s the code from my example (just snippets).

    Fix Step 4

    var
      R: THTTPRIO;
      C: IVMProvisionCore;
    begin
      R:= THTTPRIO.Create(NIL);
      C:= GetIVMProvisionCore(False, TheURL, R);
      R.Converter.Options:= R.Converter.Options + [soLiteralParams];
    

    And now – my Delphi 2007 app can talk to the C#, stand-alone, non-IIS, WCF web service!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.