473,404 Members | 2,179 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,404 software developers and data experts.

(WS-Security): Soap Header and Security elements missing in the SoapRequest.

Hello,

I am creating a webservice that collects user information and stores it in a database. Since the user information contains sensitive data like SSN I am planning to use WS-Security (WSE 2.0) in my WebService to digitally sign and encrypt the data.

Here are the steps I followed to digitally sign the message:


1) I created a X.509 certificate using Certification Services in Windows Server 2003.

2) I installed the certificate on my development machine in 'Local Computer' Store and 'Current User' Store using MMC

3) Using X.509 Certification tool , I granted full control access to ASPNET machine account on the certificates.

4) I created a test WebService.

5) I created a client that sends in some test data to the Service. On the client side I retrieved the certificate from the 'Local Computer' store and used it to digitally sign the request.(RequestSoapContext) .

6) On the Service side I implemented SoapExtension to trap the incoming XML (SoapRequest).

Client side code:

SoapContext context = proxy.RequestSoapContext;

X509CertificateStore store = X509CertificateStore.LocalMachineStore(X509Certifi cateStore.MyStore);
if(store.OpenRead())
{
X509CertificateCollection certs = store.FindCertificateByKeyIdentifier(Convert.FromB ase64String(keyIdentifier));
if(certs.Count > 0)
{
X509SecurityToken token = new X509SecurityToken(certs[0]);
if(token != null)
{
context.Security.Tokens.Add(token);
context.Security.Elements.Add(new MessageSignature(token));
}
}
}

Response.Text = proxy.HelloWorld("Hello World");


When I run the application, the client side seems to retrieve the certificate and add the appropriate objects to Tokens and Security collections of the RequestSoapContext.

But when I check the XML (SoapRequest) on the Services side using SoapExtension, I do not see the <Soap:Header> and <wsse:Security> elements in SoapRequest.

**** - Before DeSerialize: (SoapRequest) ****

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

<soap:Body wsu:Id="Id-bb057f21-19f8-4804-a49f-d952affa4020">
<HelloWorld xmlns="http://tempuri.org/">
<name>Hello World</name>
</HelloWorld>
</soap:Body>
</soap:Envelope>


I do not know what I am doing wrong. As far as I know when I add a 'MessageSignature' object to the 'Security' collection of RequestSoapContext a <Header> and <Security> element should be created and the digital signature of the message should be placed in that. I can see some wsu:Id="Id-bb057f21-19f8-4804-a49f-d952affa4020 in the message but I don't understand what that means.

Note:

1) I am retrieving the XML (SoapRequest) before DeSerialization on the Service side.
2) There is no problem on the Webservice response. The client receives a valid response and displays it on the form.

Any help would be greatly appreciated.

Thanks,
Sep 17 '07 #1
1 6063
Hi,

Create a Trace in Web.Config/App.config then you can see the full header in the inputTrace.webinfo.

Use WSE Setting 2.0 to add it automatically.
<microsoft.web.services2>
<diagnostics>
<trace enabled="true" input="InputTrace.webinfo" output="OutputTrace.webinfo" />
</diagnostics>
</microsoft.web.services2>


Siva


Hello,

I am creating a webservice that collects user information and stores it in a database. Since the user information contains sensitive data like SSN I am planning to use WS-Security (WSE 2.0) in my WebService to digitally sign and encrypt the data.

Here are the steps I followed to digitally sign the message:


1) I created a X.509 certificate using Certification Services in Windows Server 2003.

2) I installed the certificate on my development machine in 'Local Computer' Store and 'Current User' Store using MMC

3) Using X.509 Certification tool , I granted full control access to ASPNET machine account on the certificates.

4) I created a test WebService.

5) I created a client that sends in some test data to the Service. On the client side I retrieved the certificate from the 'Local Computer' store and used it to digitally sign the request.(RequestSoapContext) .

6) On the Service side I implemented SoapExtension to trap the incoming XML (SoapRequest).

Client side code:

SoapContext context = proxy.RequestSoapContext;

X509CertificateStore store = X509CertificateStore.LocalMachineStore(X509Certifi cateStore.MyStore);
if(store.OpenRead())
{
X509CertificateCollection certs = store.FindCertificateByKeyIdentifier(Convert.FromB ase64String(keyIdentifier));
if(certs.Count > 0)
{
X509SecurityToken token = new X509SecurityToken(certs[0]);
if(token != null)
{
context.Security.Tokens.Add(token);
context.Security.Elements.Add(new MessageSignature(token));
}
}
}

Response.Text = proxy.HelloWorld("Hello World");


When I run the application, the client side seems to retrieve the certificate and add the appropriate objects to Tokens and Security collections of the RequestSoapContext.

But when I check the XML (SoapRequest) on the Services side using SoapExtension, I do not see the <Soap:Header> and <wsse:Security> elements in SoapRequest.

**** - Before DeSerialize: (SoapRequest) ****

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

<soap:Body wsu:Id="Id-bb057f21-19f8-4804-a49f-d952affa4020">
<HelloWorld xmlns="http://tempuri.org/">
<name>Hello World</name>
</HelloWorld>
</soap:Body>
</soap:Envelope>


I do not know what I am doing wrong. As far as I know when I add a 'MessageSignature' object to the 'Security' collection of RequestSoapContext a <Header> and <Security> element should be created and the digital signature of the message should be placed in that. I can see some wsu:Id="Id-bb057f21-19f8-4804-a49f-d952affa4020 in the message but I don't understand what that means.

Note:

1) I am retrieving the XML (SoapRequest) before DeSerialization on the Service side.
2) There is no problem on the Webservice response. The client receives a valid response and displays it on the form.

Any help would be greatly appreciated.

Thanks,
Oct 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: john deviney | last post by:
I have a C#/.Net 1.1 client talking to a Java based web service. I need to insert a soap header on the client side which is expected on the server side. Currently, the Java ws provider, Axis, does...
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...
6
by: Peter van der veen | last post by:
Hi I have the following problem. I'm calling a webservice from within a VB.net 2005 Windows program. For this i got a WSDL file and loaded that in VB. Until now i just call the webservice and...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
6
by: John | last post by:
I'm trying to call a Webservice (Non-.NET) That requires the insertion of security credentials into the SOAP header. Up until know I've been creating Dynamic proxy classes to call web services and...
1
by: dalh | last post by:
Hi all, I'm developing an asp.net app that connect to a webservice. - I've installed an P7k certificate in the IIS-website configuration. When running my code, I have following error:...
0
by: sskvp | last post by:
There are millions of samples in the internet explain how to insert a multi node SOAP Header. What I mean is that there are plenty of examples in the internet show how to do the following:...
0
by: sskvp | last post by:
There are millions of samples in the internet that explains how to insert a multi node SOAP Header. What I mean is that there are plenty of examples in the internet show how to do the following:...
0
by: pcsharpuser | last post by:
I'm using webservices written in java from a C#.net application. For this I have referenced the Microsoft.Web.Services3 dll. I have added the username token to this using the below code. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.