Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Because the web service is located behind a proxy, a redirection URL and a destination URL have to be<br />
specified when initializing the proxy class.<br />
UploadServiceDestination ht tps://ebill-test.yellowworld.ch:9443/B2BWebServices/UploadInvoice.asmx<br />
UploadServiceVia ht tps://ebill-test.yellowworld.ch/B2BWebServices/UploadInvoice.asmx<br />
UsernameToken token = new UsernameToken( Username, Password, PasswordOption.SendPlainText );<br />
UploadInvoiceProxy.UploadInvoiceProxy uploadProxy = new<br />
UploadInvoiceProxy.UploadInvoiceProxy();<br />
Microsoft.Web.Services2.Addressing.EndpointReference epr = new<br />
Microsoft.Web.Services2.Addressing.EndpointReference(new<br />
Uri(ConfigurationSettings.AppSettings["UploadServiceDestination"]));<br />
epr.Via = new Uri(ConfigurationSettings.AppSettings["UploadServiceVia"]);<br />
uploadProxy.Destination = epr;<br />
uploadProxy.RequestSoapContext.Security.Tokens.Add( token );<br />
For stronger authentication security it’s fairly recommended to use additionally to the username token,<br />
the binary security token (for further information refer to<br />
ht tp://ww w.oasis-open.org/committees/download.php/16785/wss-v1.1-spec-os-x509TokenProfile.pdf).<br />
To use a binary security token, a client certificate is required. The following example shows how to<br />
implement a binary security token in a webservice client.<br />
// create SecurityToken<br />
X509SecurityToken x509Token = new X509SecurityToken(x509Certificate);<br />
// add SecurityToken<br />
uploadProxy.RequestSoapContext.Security.Tokens.Add(x509Token);<br />
// sign the message<br />
uploadProxy.RequestSoapContext.Security.Elements.Add(new MessageSignature(x509Token));<br />
For a further level of security, WS-Security defines a timestamp<br />
ht tp://w ww.oasis-open.org/committees/download.php/16790/wss-v1.1-spec-os-SOAPMessageSecurity.pdf<br />
with which you can ensure that the request is only valid for a certain time period.<br />
uploadProxy.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60;<br />
Now comes the actual web service call.<br />
npInvoices = uploadProxy.UploadFiles(invoices, BillerID);<br />
The client must have the time zone set to GMT +1 and the time difference between client and server may<br />
not exceed more than 1 minute.<br />
Finally, a simple evaluation of the returned value is performed.<br />
StringBuilder sb = new StringBuilder();<br />
if (npInvoices != null && npInvoices.Length > 0)<br />
{<br />
sb.Append("Nicht eingelieferte Files!\r\n");<br />
sb.Append("**************************\r\n\r\n");<br />
for (int i=0; i