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!
I've spoken with other people who have had similar problems with serialization in Delphi, and it seems that there is no clear-cut way to fix this issue.
Instead, the solution I've gone with is to attach an event handler to the OnBeforeExecute event of the THTTPRIO object that sends the SOAP message, which gives you access to the serialized soap message as a string. From there I just parsed out the attribute that was causing the problem, and now everything works.
A bit of an ugly solution, but it works.
Best Answer
You Should First create a new VCL project, and then go to
File | New | Other | Delphi Projects | WebServices | WSDL Importer