SOAP / Example of integration in C #
To be able to use the SOAP service, you must add Service References in your project specifying the url as a parameter: https://soap.serwersms.pl/server.php?wsdl
The following is an example of how to send an SMS via this service:
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Channels;
var service = new namespace.Service.SerwerSMSplPortTypeClient();
service.ClientCredentials.UserName.UserName= "demo";
service.ClientCredentials.UserName.Password = "demo";
try {
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("UTF-8")
.GetBytes(service.ClientCredentials.UserName.UserName + ":" + service.ClientCredentials.UserName.Password));
HttpRequestMessageProperty request = new HttpRequestMessageProperty();
request.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + encoded;
OperationContextScope clientScope = new OperationContextScope(service.InnerChannel);
OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, request);
soap.Service.paramsMessageSendSms param = new namespace.Service.paramsMessageSendSms { };
param.details = true;
var response = service.messages_sendSms("500000002", "sender", "text", param);
Console.WriteLine(response);
} catch(Exception e) { Console.WriteLine("{0} Exception caught.", e); } }
}