I have received a WSDL and XSD from our trading partner. The WSDL represents a service that I must create and then expose so that the trading partner can call in with SalesOrderAcknowledgments.
I have processed the WSDL using svcutil.exe Runtime Version:4.0.30319.1008. SvcUtil generates a C# class with the contract interface and classes to support the client. I have built a service that consumes the contract and exposes it with http binding.
I created a test client to try and consume the service. I turn on my service and use Add Service Reference to setup the client side of the transaction.
The Problem
When I use the service code generated by svcutil, the service reference code does not contain the necessary implementation for the client.
I found what seems like a fix!
I can modify the code generated by svcutil. Instead of [OperationContractAttribute] I change it to use [OperationContract]. Now, I turn on the host and add a service reference and the generated client code is there...but the Operation Action is different from the original WSDL.
Code Examples
The WSDL
Portion of the SvcUtil Output
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.partner.com/wsdl/SNS/SalesOrderAcknowledgmentReceipt", ConfigurationName = "SalesOrderAcknowledgmentReceiptPortType")]
public interface SalesOrderAcknowledgmentReceiptPortType
{
// CODEGEN: Generating message contract since the operation SalesOrderAcknowledgmentReceipt is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(Action = "http://www.partner.com/schemas/SNS/SalesOrderAcknowledgmentReceipt/SalesOrderA" +
"cknowledgmentReceipt", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
SalesOrderAcknowledgmentReceiptResponse SalesOrderAcknowledgmentReceipt(SalesOrderAcknowledgmentReceiptRequest request);
}
Here's the broken Service Reference Code generated based on [OperationContractAttribute]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://www.partner.com/wsdl/SNS/SalesOrderAcknowledgmentReceipt", ConfigurationName="SOAckService2Ref.SalesOrderAcknowledgmentReceiptPortType")]
public interface SalesOrderAcknowledgmentReceiptPortType {
}
The Change to the Contract Interface that seems to make it work
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.partner.com/wsdl/SNS/SalesOrderAcknowledgmentReceipt", ConfigurationName = "SalesOrderAcknowledgmentReceiptPortType")]
public interface SalesOrderAcknowledgmentReceiptPortType
{
// CODEGEN: Generating message contract since the operation SalesOrderAcknowledgmentReceipt is neither RPC nor document wrapped.
[System.ServiceModel.OperationContract]
[System.ServiceModel.XmlSerializerFormatAttribute()]
SalesOrderAcknowledgmentReceiptResponse SalesOrderAcknowledgmentReceipt(SalesOrderAcknowledgmentReceiptRequest request);
}
Here's the Service Reference Code generated based on [OperationContract]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://www.partner.com/wsdl/SNS/SalesOrderAcknowledgmentReceipt", ConfigurationName="SOAckService1Ref.SalesOrderAcknowledgmentReceiptPortType")]
public interface SalesOrderAcknowledgmentReceiptPortType {eur
// CODEGEN: Generating message contract since the operation SalesOrderAcknowledgmentReceipt is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(Action="http://www.partner.com/wsdl/SNS/SalesOrderAcknowledgmentReceipt/SalesOrderAckn" +
"owledgmentReceiptPortType/SalesOrderAcknowledgmentReceipt", ReplyAction="http://www.partner.com/wsdl/SNS/SalesOrderAcknowledgmentReceipt/SalesOrderAckn" +
"owledgmentReceiptPortType/SalesOrderAcknowledgmentReceiptResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
SOAConsole.SOAckService1Ref.SalesOrderAcknowledgmentReceiptResponse SalesOrderAcknowledgmentReceipt(SOAConsole.SOAckService1Ref.SalesOrderAcknowledgmentReceiptRequest request);
}
See the incorrect action? http://www.partner.com/wsdl/SNS/SalesOrderAcknowledgmentReceipt/SalesOrderAcknowledgmentReceiptPortType/SalesOrderAcknowledgmentReceipt
Replies
Know the answer? Post it — somebody with the same question will find it here.