Last post Jan 30, 2019 04:06 PM by kheiman61
Jan 02, 2019 09:15 AM|mdo12|LINK
I'm trying to use C # and VS Community 2017 (on Windows Serwer 2008 R2 Standard, mayby it's important ) to connect to webservers (http://currencyconverter.kowabunga.net/converter.asmx) and get a list of currencies (GetCurrencies).
private void button1_Click (object sender, EventArgs e)
TestWebserwice.ServiceReference1.ConverterSoapClient client = new TestWebserwice.ServiceReference1.ConverterSoapClient ("ConverterSoap12");
var response1 = client.GetCurrencies ();
var result2 = MessageBox.Show (response1.ToString ());
In response (var response1 = client.GetCurrencies ();), I get the error:
System.ServiceModel.Security.MessageSecurityException: 'The HTTP request was forbidden with client authentication scheme' Anonymous '.'
WebException: The remote server returned an error: (403) Forbidden.
There are no errors when trying to download data with the curl.
curl --verbose -GET currencyconverter.kowabunga.net/converter.asmx/GetCurr
* Trying 126.96.36.199 ...
* TCP_NODELAY set
* Connected to currencyconverter.kowabunga.net (188.8.131.52) port 80 (# 0)
> GET /converter.asmx/GetCurrencies? HTTP / 1.1
> Host: currencyconverter.kowabunga.net
> User-Agent: curl / 7.58.0
> Accept: * / *
<HTTP / 1.1 200 OK
<Cache-Control: private, max-age = 0
<Content-Type: text / xml; charset = utf-8
<Server: Microsoft-IIS / 7.5
<P3P: CP = "NID DSP COR"
<Date: Tue, 01 Jan 2019 19:42:07 GMT
<? xml version = "1.0" encoding = "utf-8"?>
<ArrayOfString xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns = "http: // tempuri .org / ">
<String> AUD </ string>
<String> BGN </ string>
<String> BRL </ string>
<String> CAD </ string>
Curl does not need any authentication.
What am I doing wrong in C#?
Jan 03, 2019 06:22 AM|Ackerly Xu|LINK
I have tried to call their service through browser and I successfully call the service.
But when you use a asmx client to call the webservice,you should provide Credential.
You could refer to the link below,it could also call the service through browser but when calling it from asmx client,it provides the credential.
And another guide for solve authentication.
Jan 30, 2019 04:06 PM|kheiman61|LINK
Using Fiddler, Postman and Visual Studio 2017 I did some quick testing and it seems that the .NET Soap Client is not sending a User-Agent. If you use Fiddler or Postman you can see that calls to this particular service with User-Agent (of any value, I tested
with 'User-Agent: test') succeed and calls without a User-Agent header do not. Since you are in .NET already, it looks like you have a few choices.