Java and .NET's WS-Security-based Web Services integration implementation (on)

zhaozj2021-02-17  37

Java and .NET's WS-Security-based Web Services integration implementation

RottenApple

This article applies to readers:

Web Services Developers

Knowledge that should be available:

Using VS.NET2003 WSE developed Web Services, you will develop simple Java applications using JBuilder9.

One: Introduction

WS-Security describes SOAP messaging enhancements that provide protection quality through message integrity, message confidentiality, and separate message authentication. Suitable for the following occasions:

1. Customers must be able to determine which person comes from from from the message, can confirm that the sender is the sender claimed by the sender.

2. Customers must be able to determine that the data transmitted is not tampered.

This article describes how to implement the Java client program based on the WS-Security protocol and the integrated call of .NET's Web Services.

Two: Platform and Tools

Operating system: Win2000 Server

Software: vs.net2003 WSE1.0 SP1

JBuilder9

AXIS-WSSE-1.0 (WS-Security implemented by AXIS)

Three: Implementation

1. Open vs.net2003, create a new ASP.NET Web Services project. Add a Web Services page named SUMSERVICE, whose core code is as follows:

[SOAPRPCMETHOD (Action = "http://www.contoso.com/rpc", requestnamespace = "http://www.contoso.com/su", responsenamespace = "http://www.contoso.com/su" )]]

[WebMethod]

Public int INTADD (Int A, INT B)

{

SOAPCONTEXT RequestContext = httpsoapcontext.requestcontext;

IF (RequestContext == NULL)

Throw New ApplicationException ("Only SOAP Requests Are Permitted.");

RETURN A B;

}

2. Setting this ASP Web Services using WSE SETTING TOE functions and add a password providing class (PasswordProvider) to implement WS-Security security certification in the Security option bar. At the same time, the TRACE function is selected to track the receipt of this Web Services request SOAP information and the return SOAP information.

3. Add a Microsoft.Web.Services reference, add a new Class, named PasswordProvider, which implements the iPasswordProvider interface in WSE to provide WS-Security user authentication. The core code is as follows:

Public Class PasswordProvider: iPasswordProvider

{

Public PasswordProvider ()

{

//

// Todo: add constructor logic here

//

}

Public String getPassword (UserNameToken token)

{

IF (token.username == "username")

{

Return "Password";

}

Else

{

Return "Love";

}

}

}

At this point, a Web Services that implements UserNameToken in WS-Security is basically implemented. At this time, it is recommended to use .NET first develop a client to test, and then develop the corresponding Java client program after successful test. (How to develop, please see my previous article about WSE or to see the Microsoft MSDN)

转载请注明原文地址:https://www.9cbs.com/read-30528.html

New Post(0)