WSE Summary

zhaozj2021-02-17  31

WSE Summary

One: Summary

1. WSE1.0 SP1

WSE (Web Services Enhancements) is a component (DLL) provided by Microsoft's implementation of WS-Security, WS-Routing, WS-Attachments and Dime, etc. It makes developers to develop corresponding Web Services programs without deep understanding of the specific content of the above agreement, greatly simplifying development difficulty, making Web Services applications possible on enterprise projects.

2. Common use

▲ Add / modify custom SOAP Header

▲ Add Identity Verification

▲ Encrypt SOAPBODY information

▲ Use accessories

▲ Add SOAP ROUTER information

2: Design

2.1 Proposal:

In an online procurement system, each supplier is provided to a WebServices in the purchase side, with a WebMethod providing a list of goods. The name of this WebMethod can be different, but it provides the same interface. Here, we assume that two entry parameters are required, returning a String type XML file. As for why it is necessary to need two parameters, as described later in this article. In practical implementation, the interface can be developed, so that you can maximize Proxy.

A purchaser hopes to get the best procurement program (this article only discusses technical level, interpersonal relationship, company relationship, etc., then it will join more suppliers as much as possible. It is possible that there is a new supplier to join every day, so you need a purchaser system to be an expandable system. In this example, when the purchaser needs to query a component's supply information, it will use a method called getProduct (String Name) to call all WebServices, and summarize the resulting return result. Since this article is just an introduction WSE, therefore, there is only a multi-disciplinary problem. Because this project is a temporary Du, therefore is not perfect in many ways, but I just describe WSE in use, is a pure technology discussion.

Since there will be new WebService to be added, if we add Web services to Web Services using the add web reference, then write the program and lose flexibility and scalability. Therefore, we need to generate proxy based on WSDL of WebServices, and compile into a corresponding DLL. Here, we can define a serviceID as the primary key to uniquely specify a WebServices. In actual development, we will use Proxy, Factory design mode to perform system design, generate different WDSL's proxy, and PROXY constructs into relatively independent modules. We will use the WSDL.exe application, and .NET Reflecting features.

When calling WebService or receives return information, we may need to add additional things, such as identity authentication, custom soapHeader, encryption, here I will use Microsoft's WSE1.0 to implement. How to implement QUICKSTART that can refer to Microsoft. It is included in the download package of WSE1.0SP1, the specific location is as follows:

Http://www.microsoft.com/downloads/details.aspx?familyid=06255a94-2635-4d29-a90c-28b282993a41&displayLANG=EN

2.2 Production and use of Proxy

1. Automatically generate proxy files (PrxoyFactory, using WSDL.exe) based on WSDL, to generate Proxy's CS files yourself according to the supplied WSDL addresses. The main code is as follows:

String parameter = WSDLURL;

Parameter = "/ L: C #";

Parameter = "/ N: serviceID;

Parameter = "/ o:" Constants.Library_path "//" ServiceID ".cs";

// use serviceid as output file name

Try

{

ProcessStartInfo StartInfo = New ProcessStartInfo (constants.wsdl_path, parameter);

Process process.start (StartInfo);

Process.waitForexit ();

IF (Process.exitcode! = 0)

Throw New Exception ("Generate Proxy Error");

Return True;

}

Catch (Exception EX)

{

}

Example 2.1

2. Modify the generated proxy file, change the original inheritance httpwebclientprotocol to Microsoft.Web.Services.WebserviceSClientProtocol

3. According to the database content, add different PIPELINE (PIPELINEFAACTORY) for different proxy

Every Proxy will have a Microsoft's default Pipeline. This pipeline will include proxy to need the OutputFilter, InputFilter, and all Filter order is critical. Therefore, we specify a unique serviceID when designing a WebServices, and the Filter that needs to be used is added to the database. The table should have this Filte type (I / O), order, name, etc. :

4. In Proxy, the method of Invoke WebService should be different depending on the different webmethod name.

As follows:

Object [] results = this.invoke (pipeline.Operationname, new object [] {

Msgid,

SXML});

5. If you want to join the Filter in ASP.NET WebService, you can only join in an application_start () of the global.asax file. Therefore, if multiple webmethods are provided in a WebService, and for different webmethod may require different filters (may not be not). In this case, WebMethod can be separated to make multiple WebService. Filter in each of global.asaz only works on the request / response of your Visual Folder.

6. It should be noted that if we need to join Filter (providing decryption, verification) on a WebServices Server, then we have two ways as a choice. One is an application_start () in the global.asax file to join all Filter, and the other is to join in Web.config. This way, all SOAP requests for this virtual directory will pass through these filters. However, if this WebServices provides two webmethod, and only one of them needs Filter, and the other is not required, the above method cannot be implemented. How can I dynamically assign each SOAP request to all the Filter is also the problem I want to know (similar to the proxy request side), everyone knows, I can tell me, thank you. Reference: http://msdn.microsoft.com/webservices/building/wse/default.aspx

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

New Post(0)