Requirements:
- The client must provide the WSDL of the SOAP Web service at run time. i) select the WSDL file from the file sharing folder.
- Use WSDL and call the method selected by the Client in the user interface, and process the response.
I can not use MetadataExchangeClient, because WSDL will not be hosted.
Implementation:
var serviceDescription = ServiceDescription.Read(@"C:\Contacts.WSDL"); var metadataSection = new MetadataSection { Dialect = MetadataSection.ServiceDescriptionDialect, Identifier = serviceDescription.TargetNamespace, Metadata = serviceDescription }; var metadataSections = new List<MetadataSection> {metadataSection}; var metadatSet = new MetadataSet(metadataSections); var wsdlImporter = new WsdlImporter(metadatSet); var services = wsdlImporter.ImportAllEndpoints();
Road blocks:
- The above code could not retrieve the service endpoints at all. So, I had to manually create the service endpoint.
- I could not list all the methods contained in the above WSDL, and the related I / O in the step (for use in the variables operationName and operationParameters below)
object retVal = instance.GetType().GetMethod(operationName) .Invoke(instance, operationParameters);
I tried hard-coded the name of the operation, manually parsed from WSDL, but then it failed in the parameters. It expects a complex type containing a hierarchy, as shown below:
ContactInput → ListOfContacts → Contact → FirstName, LastName
Next steps:
If someone can help me fix the roadblocks, I can continue this approach.
Finally, I have to start researching the use of svcutil.exe at runtime
Thanks Dev
source share