Important disclaimer. This question isn't about generating a proxy to WSDL. It's not about creating a reference in VS Code, neither.
I'm using Visual Studio Code (latest update, v1.8 November 16) and I need to create a call to an external web service described using a WSDL and XSD file. I want to do that using the aforementioned editor and preferably not have to compose all the proxies and enveloping myself.
Is it possible or am I out of luck on this one?
What would be the simplest alternative if it's not doable in VS Code? Are we talking about generating the classes and calls using VS15 and copying over the files or is there a neat workaround I'm not familiar with?
If building from scratch and don't care about how Visual Studio does it, you can start with some basics from this solution here, as well as the other links referenced in the accepted solution on the same page.
For reference, some of the files generated by the Visual Studio add reference method below, are stored within a subfolder Web References/Example (where Example is the name of the variable used to access the reference) and contains the following :
<?xml version="1.0" encoding="utf-8"?>
<DiscoveryClientResultsFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Results>
<DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://example.com/api/index.php?wsdl" filename="index.wsdl" />
</Results>
</DiscoveryClientResultsFile>
This file is the complete raw wsdl source file (well formatted xml).
This file contains code to initialize all the methods and properties and is the base class which extends System.Web.Services.Protocols.SoapHttpClientProtocol
The properties assigned to the class (sorry I am stripping from an old VB.NET project: look like the following :
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.6.1586.0"), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Web.Services.WebServiceBindingAttribute(Name:="ExampleAPIBinding", [Namespace]:="urn:ExampleAPI"), _
System.Xml.Serialization.SoapIncludeAttribute(GetType(MyCustomType1)), _
System.Xml.Serialization.SoapIncludeAttribute(GetType(MyCustomType2)), _
Partial Public Class ExampleAPI
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
End Class
.datasource (1 file for each type)
Example code
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="MyMethodName" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>ExampleAPI.SOAP.ClientMerchant, Web References.SOAP.Reference.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
Inside Visual Studio, you can do the following (and copy the results out to your VSCode project)
Right-click your project in Project explorer, and select Add > Service Reference..
Click [Advanced] on this screen
Click [Add Web Reference] on this screen
Enter your full URL to the WSDL location and press Enter.
If successful (well formatted WSDL is found), the [Add Reference] button will be enabled. Click that, and it will add the reference to your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With