.NET examples
In this article:
To access the shop API from a .NET environment, a proxy client must be loaded. The proxy can be autogenerated by Visual Studio by following this guide.
- Right-click on References in your project and select "Add Service Reference...":
- Enter the URL of the WSDL file in the "Address" field and click the "Go" button. The URL is:
https://api.hostedshop.io/service.wsdl - You will now see the class "WebServicePort" in the left column and all available methods for the API on the right side:
- Under "Namespace" you now need to give the reference a name. In this case, we will call it "WebService". Click OK.
- Now open the "App.Config" file in your project in Visual Studio and find the binding called "WebServiceBinding". Here you need to add the attribute allowCookies="true" to allow the connection to the api to be saved in a session.
- Use the following example to print a list of products and their variants for a solution in the .NET console. In the example, our new service reference is under the name "ConsoleApplication1.WebService". You can use a specific API user to log in, but if you don't have one, you can use the solution's general login information.
As seen above, the proxy itself handles the wrapping of input and output arguments. The proxy is generated from https://api.hostedshop.io/service.wsdl. Please see section 2 or https://api.hostedshop.io/doc/ for a detailed documentation of the different method calls available, as they are the same for PHP and .NET.