I have been trying to create a service from a supplied WSDL for an API that we need to hook into. The way this works is that we have to create the service for the API to call into and send back information to the caller. I used svcutil to create the service
contract and discovered that all the Action properties were blank, which meant that it would not compile. This then lead me to this post https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/dispatch-by-body-element and
on checking, I found that indeed the soapAction in the WSDL for all functions was blank. I added the three classes from the example link into my project , added the DispatchByBodyElementBehavior property, added a default method and set the other OperationContractAttribute
properties as per the article. The service then compiles and runs. However, if I try and create a client for it from the service I created using Visual Studio or svcutil , it has no functions. Also if I use the WCF Test Client (by starting the VS project with
the .svc file selected), I get an error message "The contract 'IViatorWCFService' in client configuration does not match the name in service contract, or there is no valid method in this contract." I have checked "always regenerate config when launching services"
and refreshed but no change. The problem is possibly to do with the wild cards for ReplyAction , which is what the article indicated was required. I have tried leaving a question ion the original article, but have had no reply. I have also contacted the supplier
of the wsdl (Viator) but at this stage have not had any replies. The code for the interface is below. There are a bunch of other classes and properties from the WSDL, but I have not pasted those here. I am new to WCF , so I'm struggling to work out what he
issue is
Help !
Many thanks in advance
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://toursgds.com/api/01", ConfigurationName = "Custom.ViatorWebService.IViatorWCFService"), DispatchByBodyElementBehavior]
public interface IViatorWCFService
{
[OperationContractAttribute(Action = "*", ReplyAction = "*")]
void DefaultOperation();
// CODEGEN: Generating message contract since the operation cancelBooking is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(ReplyAction = "*"), DispatchBodyElement("cancelBooking", "http://toursgds.com/api/01")]
[System.ServiceModel.FaultContractAttribute(typeof(Custom.ViatorWebService.Error), Action = "", Name = "RequestError")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourAvailabilityBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TransactionStatus))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourOptionsBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(RequestResponseBase))]
Custom.ViatorWebService.BookingCancellationResponse1 cancelBooking(Custom.ViatorWebService.BookingCancellationRequest1 request);
// CODEGEN: Generating message contract since the operation sendBookingNotification is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(ReplyAction="*"), DispatchBodyElement("sendBookingNotification", "http://toursgds.com/api/01")]
[System.ServiceModel.FaultContractAttribute(typeof(Custom.ViatorWebService.Error), Action = "", Name = "RequestError")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourAvailabilityBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TransactionStatus))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourOptionsBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(RequestResponseBase))]
Custom.ViatorWebService.BookingNotificationResponse1 sendBookingNotification(Custom.ViatorWebService.BookingNotificationRequest1 request);
// CODEGEN: Generating message contract since the operation getTourList is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(ReplyAction="*"), DispatchBodyElement("getTourList", "http://toursgds.com/api/01")]
[System.ServiceModel.FaultContractAttribute(typeof(Custom.ViatorWebService.Error), Action = "", Name = "RequestError")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourAvailabilityBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TransactionStatus))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourOptionsBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(RequestResponseBase))]
Custom.ViatorWebService.TourListResponse1 getTourList(Custom.ViatorWebService.TourListRequest1 request);
// CODEGEN: Generating message contract since the operation getAvailability is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(ReplyAction="*"), DispatchBodyElement("getAvailability", "http://toursgds.com/api/01")]
[System.ServiceModel.FaultContractAttribute(typeof(Custom.ViatorWebService.Error), Action = "", Name = "RequestError")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourAvailabilityBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TransactionStatus))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourOptionsBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(RequestResponseBase))]
Custom.ViatorWebService.AvailabilityResponse1 getAvailability(Custom.ViatorWebService.AvailabilityRequest1 request);
// CODEGEN: Generating message contract since the operation amendBooking is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(ReplyAction="*"), DispatchBodyElement("amendBooking", "http://toursgds.com/api/01")]
[System.ServiceModel.FaultContractAttribute(typeof(Custom.ViatorWebService.Error), Action = "", Name = "RequestError")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourAvailabilityBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TransactionStatus))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourOptionsBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(RequestResponseBase))]
Custom.ViatorWebService.BookingAmendmentResponse1 amendBooking(Custom.ViatorWebService.BookingAmendmentRequest1 request);
// CODEGEN: Generating message contract since the operation getBatchAvailability is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(ReplyAction="*"), DispatchBodyElement("getBatchAvailability", "http://toursgds.com/api/01")]
[System.ServiceModel.FaultContractAttribute(typeof(Custom.ViatorWebService.Error), Action = "", Name = "RequestError")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourAvailabilityBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TransactionStatus))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourOptionsBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(RequestResponseBase))]
Custom.ViatorWebService.BatchAvailabilityResponse1 getBatchAvailability(Custom.ViatorWebService.BatchAvailabilityRequest1 request);
// CODEGEN: Generating message contract since the operation makeBooking is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(ReplyAction="*"), DispatchBodyElement("makeBooking", "http://toursgds.com/api/01")]
[System.ServiceModel.FaultContractAttribute(typeof(Custom.ViatorWebService.Error), Action = "", Name = "RequestError")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourAvailabilityBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TransactionStatus))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(TourOptionsBase))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(RequestResponseBase))]
Custom.ViatorWebService.BookingResponse1 makeBooking(Custom.ViatorWebService.BookingRequest1 request);
}