472,783 Members | 993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 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 16086
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.