Skip to Content
Technical Articles
Author's profile photo Fatih Pense

.Net C# SOAP Web Service Client Example for SAP PI/PO Services

I was helping a friend connecting to a PO Web Service from .Net. It was not straightforward enough and I haven’t found a good example so I decided to share the code with you. For simplicity, It is a console application.

(Update: If you are using .Net Core or .Net version > 5, check out my other post here)

Features are:

  • Using SOAP 1.1
  • Basic authentication over HTTP
  • Specifying endpoint


First, we add a Service Reference


We can give a Web URL or file path:


Add your C# namespace to the main class.

using ConsoleApplication4.ServiceReference2;


And the example code block:

static void Main(string[] args)

	BasicHttpBinding binding = new BasicHttpBinding();
	binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
	binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

	EndpointAddress endpoint = new EndpointAddress("http://hostname:port/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SENDER_SYSTEM0&receiverParty=&receiverService=&interface=SI_SEND_ORG_DATA&interfaceNamespace=");
	SI_SEND_ORG_DATAClient client = new SI_SEND_ORG_DATAClient(binding, endpoint);

	client.ClientCredentials.UserName.UserName = "Username";
	client.ClientCredentials.UserName.Password = "Password";

	ZHRS_SEND_ORG_LINE[] result = client.SI_SEND_ORG_DATA("1234");


If you have any questions, please ask in the comments.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Alexander Apel
      Alexander Apel

      Hi Fatih,

      can you please create an example with the standard webService "Adapter Message Monitoring / basic? Style = document" and "getMessageList"?
      So I have my problems with this.

      best regards,



      Author's profile photo Fatih Pense
      Fatih Pense
      Blog Post Author

      Hi Alexander,

      I was able to use those services with SOAPUI and created a Java application using them in the past. I will try using C# when I have the time. Can you describe where you get stuck?

      Author's profile photo Alexander Apel
      Alexander Apel

      Hi Fatih,


      thx for your response but i solved  the issue by my self.

      For the MessageList i use a simple HttpWebRequest like this

      HttpWebRequest req = WebRequest.Create(Form1.url) as HttpWebRequest;
      req.Credentials = new NetworkCredential(Form1.usr, Form1.pwd);
      XmlDocument xmlDoc = new XmlDocument();
      using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
            xmlDoc.Save(Directory.GetCurrentDirectory() + @"\pi.xml");


      best regards,



      Author's profile photo Former Member
      Former Member


      Öncelikle örnek için teşekkürler. Örnek üzerinden bende bir işlem yaptım fakat, result aldığım sırada

      Tanınmayan ileti sürümü (Unrecognized message version) şeklinde bir hata almaktayım. Acaba binding yönteminde mi sorun var ya da SAP web servis ile ilgili bir ayar mı yapmak gerekiyor. Konu hakkında yardımcı olur musun ?


      Author's profile photo Former Member
      Former Member

      Hi Fatih,

      We've been trying to develop a C# .NET console application that will integrate with SAP PI/PO web service though the following fictitious URL:

      Whenever we run the console application the following exception is thrown everytime:

      System.ServiceModel.Security.SecurityNegotiationException: could not establish secure channel for ssl/tls with authority ''.

      However, using SoapUI to test the connection, there's no such error.

      The obvious has been checked, like Certificate validity: it's issued by GlobalSign and not self-signed, and it is not expired. The certificate path is correct and there are no errors pointed out on the Certificate when analysing it from a browser.

      What could we be missing? If more information is needed, please let me know and I'll complement this post.

      Author's profile photo Juan Gabriel Gallegos Ramirez
      Juan Gabriel Gallegos Ramirez

      Hi Fatih! Thanks for the example


      Is there any special consideration to make this example to be usable on a Sync Scenario? in my case, the "result" variable was setted as "Nothing" after call the function. I ran the service on SoapUI and it returns a message as response.