SAP PO SOAP Web Service with .NET Core client

Dear SAP PI/PO consultants,

It has been a while(3 years) since I wrote “.Net C# SOAP Web Service Client Example for SAP PI/PO Services”  .NET Core has gained popularity since then.

There is also a tendency to request REST services. However, I still think there are many valid use cases where SOAP is the better option. In order to speed up things, you can pass this blog post when you are working with .NET developers.


  • .NET Core SDK is installed

Generate Web Service Client Reference Classes & add libraries

Java wsimport equivalent of .NET Core is dotnet-svcutil

dotnet tool install --global dotnet-svcutil
dotnet tool list -g

Usually it adds the tools to the PATH. You may need to close & reopen the terminal. If that doesn’t work you should add this directory to Environment variable PATH:

Generate client classes with a WSDL:

dotnet-svcutil calculator-v1.wsdl

Generate classes with namespace:

dotnet-svcutil SI_SEND_ORG_DATA.wsdl -n *,MDP.MyAwesomePO.WSClient

This command will create a Service Reference. You can copy the class to your project. By default, it doesn’t create sync methods but there is an option for that(–sync). You can use –help to see options.

You have to add these packages to your project:

dotnet add package System.ServiceModel.Primitives
dotnet add package System.ServiceModel.Http

Don’t forget to run “dotnet restore”.

Use the Reference Classes

I like to set endpoint, username, and password programmatically. Binding configuration helps if you have to use basic authentication over HTTP.

String endpointurl = "http://hostname:port/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SENDER_SYSTEM0&receiverParty=&receiverService=&interface=SI_SEND_ORG_DATA&interfaceNamespace=";
BasicHttpBinding binding = new BasicHttpBinding();
//If you need HTTP with Basic Auth for internal network or dev environments. Otherwise remove these two lines:
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

EndpointAddress endpoint = new EndpointAddress(endpointurl);
var wsclient = new SI_SEND_ORG_DATAClient(binding, endpoint);
wsclient.ClientCredentials.UserName = "username";
wsclient.ClientCredential.Password = "password";

//Here you can use client
var request = new SI_SEND_ORG_DATA();
var response = await wsclient.SI_SEND_ORG_DATAAsync(request);


Beware of the integer/double

Coming from Java one of the things that bit me was setting an integer value for a SOAP request.

If you have a field like xsd:integer or xsd:double that maps to .Net built-in types which don’t have null, you have to set Specified value to true.

request.FirstNumber = 2;

This is a solution to differentiate between an element with 0 and no element. I’m sure you experienced this behavior while trying to send an integer with 0 value using ABAP Proxy. Because in ABAP, integer initial value is 0 and regarded as null for outbound XML processing. 🙂

See you in next blog posts!

Original Article:

Related blogs


Please enter your comment!
Please enter your name here