473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

C# SOAP Authentication to non C# web service

Hi,
I have a gSoap Web Service written using C++, it uses SOAP username and
password authentication.

I also have a C# form client consuming the web service, all this was working
fine until I added the authentication on the server, now I can not get the
client to authenticate. Can someone tell me how to add authentication info
to the SOAP message posted from the C# SOAP client.
here is some code I call to initilize the soap call from the C# form.

public partial class MyForm : Form
{
public MyForm()
{
InitializeComponent();

Service service = new Service();
}
...
...
...
I am using SOAP authentication, with a username and password. Here is the
soap request I would like to receive at the web service. It contains an
Authorization field.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:80/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:getBatteryLevel></ns2:getBatteryLevel></SOAP-ENV:Body></SOAP-ENV:Envelope>POST
/ HTTP/1.1
Host: localhost:8080
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 489
Connection: close
Authorization: Basic dXNlcjpwYXNz
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:8080/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:GetDBOldestPendingRow><iMaxRows>100</iMaxRows></ns2:GetDBOldestPendingRow></SOAP-ENV:Body></SOAP-ENV:Envelope>
Is there a way I can get this info into the C# client request?

Thanks,
Enda
Jan 15 '08 #1
3 16238
Enda,

I believe you posted this before, at least this time you answered the
question of whether or not you are using transport or message security.

Assuming you are using a web reference, you will want to set the
Credentials property on the proxy (in this case, your Service instance, I
believe) to an implementation of the ICredentials class. You would use the
NetwokCrediential instance, setting it to the username/password needed for
the website.

If you were using WCF, you would have to set up the wsHttpBinding to use
transport security, but this would only be allowed if you were using SSL
certificates (https), so that you could guarantee security (WCF won't allow
it otherwise).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Enda Manni" <en*********@hotmail.comwrote in message
news:A7**********************************@microsof t.com...
Hi,
I have a gSoap Web Service written using C++, it uses SOAP username and
password authentication.

I also have a C# form client consuming the web service, all this was
working
fine until I added the authentication on the server, now I can not get the
client to authenticate. Can someone tell me how to add authentication
info
to the SOAP message posted from the C# SOAP client.
here is some code I call to initilize the soap call from the C# form.

public partial class MyForm : Form
{
public MyForm()
{
InitializeComponent();

Service service = new Service();
}
..
..
..
I am using SOAP authentication, with a username and password. Here is
the
soap request I would like to receive at the web service. It contains an
Authorization field.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:80/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:getBatteryLevel></ns2:getBatteryLevel></SOAP-ENV:Body></SOAP-ENV:Envelope>POST
/ HTTP/1.1
Host: localhost:8080
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 489
Connection: close
Authorization: Basic dXNlcjpwYXNz
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:8080/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:GetDBOldestPendingRow><iMaxRows>100</iMaxRows></ns2:GetDBOldestPendingRow></SOAP-ENV:Body></SOAP-ENV:Envelope>
Is there a way I can get this info into the C# client request?

Thanks,
Enda


Jan 15 '08 #2
Thanks

I added

service.Credentials = new System.Net.NetworkCredential("user", "pass");
but it still does not add the authorization to the SOAP header.
Here is my code:

public MyForm()
{
InitializeComponent();

Service service = new Service();

service.Credentials = new System.Net.NetworkCredential("user",
"pass");
}

I also added a web reference, it was difficult locating it as My web service
is a c++ gSoap web service, I specified the following string to find the web
reference.

http://127.0.0.1:8080/ns1.wsdl
Any more ideas.
Enda

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:%2****************@TK2MSFTNGP03.phx.gbl...
Enda,

I believe you posted this before, at least this time you answered the
question of whether or not you are using transport or message security.

Assuming you are using a web reference, you will want to set the
Credentials property on the proxy (in this case, your Service instance, I
believe) to an implementation of the ICredentials class. You would use
the NetwokCrediential instance, setting it to the username/password needed
for the website.

If you were using WCF, you would have to set up the wsHttpBinding to
use transport security, but this would only be allowed if you were using
SSL certificates (https), so that you could guarantee security (WCF won't
allow it otherwise).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Enda Manni" <en*********@hotmail.comwrote in message
news:A7**********************************@microsof t.com...
>Hi,
I have a gSoap Web Service written using C++, it uses SOAP username and
password authentication.

I also have a C# form client consuming the web service, all this was
working
fine until I added the authentication on the server, now I can not get
the
client to authenticate. Can someone tell me how to add authentication
info
to the SOAP message posted from the C# SOAP client.
here is some code I call to initilize the soap call from the C# form.

public partial class MyForm : Form
{
public MyForm()
{
InitializeComponent();

Service service = new Service();
}
..
..
..
I am using SOAP authentication, with a username and password. Here is
the
soap request I would like to receive at the web service. It contains an
Authorization field.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:80/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:getBatteryLevel></ns2:getBatteryLevel></SOAP-ENV:Body></SOAP-ENV:Envelope>POST
/ HTTP/1.1
Host: localhost:8080
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 489
Connection: close
Authorization: Basic dXNlcjpwYXNz
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:8080/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:GetDBOldestPendingRow><iMaxRows>100</iMaxRows></ns2:GetDBOldestPendingRow></SOAP-ENV:Body></SOAP-ENV:Envelope>
Is there a way I can get this info into the C# client request?

Thanks,
Enda


Jan 15 '08 #3
Enda,

It's not supposed to add the authorization to the SOAP header. You
displayed this:

Host: localhost:8080
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 489
Connection: close
Authorization: Basic dXNlcjpwYXNz
SOAPAction: ""

Those are HTTP headers, and the Authorization field in that set of
headers is what is known as transport security. Setting the Credentials
property should set that Authorization field correctly.

If you want to use WS-Security spec, which will allow you to use
authentication/authorization on a ^message^ level, then you won't be able to
use a web reference here. You will have to use the Web Service Enhancements
from MS, or Windows Communications Foundation (WCF).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Enda Manni" <en*********@hotmail.comwrote in message
news:3A**********************************@microsof t.com...
Thanks

I added

service.Credentials = new System.Net.NetworkCredential("user", "pass");
but it still does not add the authorization to the SOAP header.
Here is my code:

public MyForm()
{
InitializeComponent();

Service service = new Service();

service.Credentials = new System.Net.NetworkCredential("user",
"pass");
}

I also added a web reference, it was difficult locating it as My web
service is a c++ gSoap web service, I specified the following string to
find the web reference.

http://127.0.0.1:8080/ns1.wsdl
Any more ideas.
Enda

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:%2****************@TK2MSFTNGP03.phx.gbl...
>Enda,

I believe you posted this before, at least this time you answered the
question of whether or not you are using transport or message security.

Assuming you are using a web reference, you will want to set the
Credentials property on the proxy (in this case, your Service instance, I
believe) to an implementation of the ICredentials class. You would use
the NetwokCrediential instance, setting it to the username/password
needed for the website.

If you were using WCF, you would have to set up the wsHttpBinding to
use transport security, but this would only be allowed if you were using
SSL certificates (https), so that you could guarantee security (WCF won't
allow it otherwise).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Enda Manni" <en*********@hotmail.comwrote in message
news:A7**********************************@microso ft.com...
>>Hi,
I have a gSoap Web Service written using C++, it uses SOAP username and
password authentication.

I also have a C# form client consuming the web service, all this was
working
fine until I added the authentication on the server, now I can not get
the
client to authenticate. Can someone tell me how to add authentication
info
to the SOAP message posted from the C# SOAP client.
here is some code I call to initilize the soap call from the C# form.

public partial class MyForm : Form
{
public MyForm()
{
InitializeComponent();

Service service = new Service();
}
..
..
..
I am using SOAP authentication, with a username and password. Here is
the
soap request I would like to receive at the web service. It contains an
Authorization field.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:80/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:getBatteryLevel></ns2:getBatteryLevel></SOAP-ENV:Body></SOAP-ENV:Envelope>POST
/ HTTP/1.1
Host: localhost:8080
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 489
Connection: close
Authorization: Basic dXNlcjpwYXNz
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://localhost:8080/Service.wsdl"
xmlns:ns2="http://tempuri.org/ns1.xsd"><SOAP-ENV:Body><ns2:GetDBOldestPendingRow><iMaxRows>100</iMaxRows></ns2:GetDBOldestPendingRow></SOAP-ENV:Body></SOAP-ENV:Envelope>
Is there a way I can get this info into the C# client request?

Thanks,
Enda



Jan 15 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nalla | last post by:
Hi, I have a requirement to call webservices from my old C++ application.So first I tried with Vc++.net as follows.....There are 2 approach Dotnet frame work and soaptoolkit 3.0 I am not able to...
0
by: Daniel Thune, MCSE | last post by:
I am having a problem with formatting a SOAP Header in a .Net client. The client calls a Java Axis 1.1 based web service. In order to authenticate the caller, the web service call is intercepted by...
1
by: LP | last post by:
Hello, I am really hoping someone can help me here. I have a web service running on Win 2003 IIS 6.0, and VB6 client connecting to it with the use of Soap Toolkit. Everything worked fine until I...
3
by: Steve Alpert | last post by:
I'm trying to see what basic authentication will do in a SOAP call through a class created in C# by the wsdl tool. WSDLTest wt = new WSDLTest(); // my SOAP class wt.Credentials = new...
1
by: Stu | last post by:
Hi, Im using vis studio 2003 and I think wse is out of the question as clients could be using java which doesnt support it. So I managed to find some code which allows you to develop a custom...
1
by: Tony Stephens | last post by:
Hi, I've created a small forms based application in c# to test a vendor's product and the web service interface that it exposes. We have deployed two instances of the vendor product one which...
0
by: KIM | last post by:
Hi! We are trying to realize message-based security with WCF June CTP. We get the messages encrypted but not signed (see SOAP-message below)! We also tried the "Message Security Sample" from the...
0
by: Albertas | last post by:
Hello, I have a question. But first my situation: I had a Web Service, which was written using .NET Framework 2.0, here is my code: public class Service : System.Web.Services.WebService {...
2
by: Enda Manni | last post by:
Hi, I have a gSoap Web Service written using C++, it uses SOAP username and password authentication. I also have a C# form client consuming the web service, all this was working fine until I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.