Summary of the invention
For solving the problems of the technologies described above, the embodiment of the present application provides a kind of Web Service availability based on OSGI to follow the tracks of and detects detection method, Apparatus and system, under the computing environment of OSGI normalized definition, Web Service is carried out effective availability follow the tracks of detection.
Technical scheme is as follows:
A kind of Web Service availability tracking detection method comprises:
Obtain WSDL (the Web Services Description Language of Web Service issue, a kind of XML language how Web service and explanation communicate by letter with Web service that is used for describing) address of document, create the resource connecting object of described address of document, using described resource connecting object is connected with the WSDL document of Web Service issue, if connect unusual, then Web Service service is unavailable, otherwise, obtain described WSDL document;
Search the Web Service address of service of appointment in the described WSDL document, create the resource connecting object of described address of service, use described resource connecting object and be connected with Web Service, if connect unusual, then Web Service service is unavailable, otherwise Web Service service is available.
Above-mentioned method, preferred, described application resource connecting object with the process that the WSDL document of Web Service issue is connected is:
Obtain Web Service by the address of the WSDL document of HTTP (HyperText Transfer Protocol, HTML (Hypertext Markup Language)) protocol issuance;
Create the HTTP resource connecting object of described WSDL address of document;
Using described HTTP resource connecting object is connected with described WSDL document.
Above-mentioned method, preferred, described application resource connecting object with the process that the WSDL document of Web Service issue is connected is:
Obtain Web Service by the address of the WSDL document of HTTPS (Hypertext Transfer Protocol over Secure Socket Layer, the HTTP passage take safety as target) protocol issuance;
Create the HTTPS resource connecting object of described WSDL address of document;
Using described HTTPS resource connecting object is connected with described WSDL document.
Above-mentioned method, preferred, described application resource connecting object is specially with the process that Web Service is connected:
Search the Web Service address of service of appointment in the described WSDL document;
Create the HTTP resource connecting object of described address of service;
Using described HTTP resource connecting object is connected with Web Service.
Above-mentioned method, preferred, described application resource connecting object is specially with the process that Web Service is connected:
Search the Web Service address of service of appointment in the described WSDL document;
Create the HTTPS resource connecting object of described address of service;
Using described HTTPS resource connecting object is connected with Web Service.
A kind of Web Service availability tracing and detecting apparatus comprises: the first address acquisition unit, first resource connecting object creating unit, the first linkage unit, the second address acquisition unit, Secondary resource connecting object creating unit and the second linkage unit;
Wherein: described the first address acquisition unit is used for obtaining the address of WSDL (Web Services Description Language is that a kind of being used for described Web service and the XML language of how to communicate by letter with the Web service is described) document of Web Service issue;
First resource connecting object creating unit creates the resource connecting object of described address of document for the address of the document that obtains according to described the first address acquisition unit;
Described the first linkage unit is connected with the WSDL document of Web Service issue for the resource connecting object of using the establishment of described first resource connection creating unit, if connect unusual, then Web Service service is unavailable, otherwise, obtain described WSDL document;
Described the second address acquisition unit is used for searching the Web Service address of service of the WSDL document appointment that described the first linkage unit obtains;
Described Secondary resource connecting object creating unit is used for creating according to the address of service that described the second address acquisition unit is searched the resource connecting object of described address of service;
Described the second linkage unit is connected with Web Service for the resource connecting object of using described Secondary resource connecting object creating unit establishment, if connect unusually, then Web Service service is unavailable, otherwise Web Service serves available.
Above-mentioned device, preferred, described first resource connecting object creating unit comprises: a HTTP resource object creates assembly and a HTTPS resource object creates assembly;
Wherein: a described HTTP resource object creates assembly and is used for creating Web Service by the HTTP resource connecting object of the address of the WSDL document of http protocol issue;
A described HTTPS resource object creates assembly and is used for creating Web Service by the HTTPS resource connecting object of the address of the WSDL document of HTTPS protocol issuance.
Above-mentioned device, preferred, described Secondary resource connecting object creating unit comprises: the 2nd HTTP resource object creates assembly and the 2nd HTTPS resource object creates assembly;
Described the 2nd HTTP resource object creates assembly and is used for creating Web Service by the HTTP resource connecting object of the address of service of http protocol issue;
Described the 2nd HTTPS resource object creates assembly and is used for creating Web Service by the HTTPS resource connecting object of the address of service of HTTPS protocol issuance.
A kind of Web Service availability is followed the tracks of detection system, comprising: client, a kind of Web Service of application end availability tracing and detecting apparatus.
The technical scheme that is provided by above the embodiment of the present application as seen, Web Service service availability tracking detection method, Apparatus and system based on OSGI provided by the invention, obtain the address of the WSDL document of Web Service issue, create the resource connecting object of described address of document, using described resource connecting object is connected with the WSDL document of Web Service issue, if connect and unusually showing that current Web Service is unavailable, otherwise, read the WSDL document and be cached to this locality; Then obtain the Web Service address of service in the WSDL document, create the resource connecting object of address of service, use described resource connecting object and be connected with Web Service, if connect unusual, then current Web Service is unavailable, otherwise Web Service can use.
By above discussion as can be known, Web Service service availability tracking detection method, Apparatus and system that the embodiment of the present application provides, successively the WSDL document of Web Service issue being connected the Web Service of appointment with the WSDL document connects, only have in the time all can connecting, show that just current Web Service service is available, notify the user to use; This method is a cyclic process to the tracking detection of Web Service, at set intervals the availability of Web Service is followed the tracks of detection, the operating position of real-time informing user current Web Service has effectively realized the real-time tracking of Web Service availability is detected.
Embodiment
The embodiment of the present application provides a kind of Web Service availability tracking detection method, Apparatus and system, to judging that the foundation that a Web Service can use is, the WSDL document of Web Service issue can with and the WSDL document in the Web Service address of appointment can use, satisfy i.e. this Web Service service of above condition available.
More than be the application's core concept, understand better the application's scheme in order to make those skilled in the art person.Below in conjunction with the accompanying drawing in the embodiment of the present application, the technical scheme in the embodiment of the present application is clearly and completely described, obviously, described embodiment only is the application's part embodiment, rather than whole embodiment.Based on the embodiment among the application, those of ordinary skills are not making the every other embodiment that obtains under the creative work prerequisite, all should belong to the scope of the application's protection.
The method flow diagram of a kind of Web Service availability tracking detection method that the embodiment of the present application provides comprises as shown in Figure 1:
Step S101: the address that obtains the WSDL document of Web Service issue;
Step S102: create the resource connecting object of WSDL address of document, use above-mentioned resource connecting object and be connected with the WSDL document of Web Service issue;
Step S103: judge whether above-mentioned resource connecting object is unusual with being connected of WSDL document; If, execution in step S109; Otherwise execution in step S104;
Step S104: the WSDL document that obtains above-mentioned Web Service issue;
Step S105: the Web Service address of service of searching appointment in the above-mentioned WSDL document;
Step S106: create the resource connecting object of above-mentioned address of service, use above-mentioned resource connecting object and be connected with Web Service;
Step S107: whether the resource connecting object of judging the Web Service address of service that creates is unusual with being connected of Web Service, if, execution in step S109; Otherwise, execution in step S108;
Step S108: notify user Web Service to serve current available;
Step S109: notify user Web Service to serve current unavailable.
The resource connecting object of address that creates the WSDL document of Web Service issue comprises two types of HTTP and HTTPS; Web Service can be by http protocol and HTTPS agreement dual mode issue WSDL document.
When Web Service issued the WSDL document by http protocol, the flow chart that the application resource connecting object that the embodiment of the present application provides is connected with the WSDL document of Web Service issue comprised as shown in Figure 2:
Step S201: obtain Web Service by the address of the WSDL document of http protocol issue;
Step S202: the HTTP resource connecting object that creates above-mentioned WSDL address of document;
Step S203: use above-mentioned HTTP resource connecting object and be connected by the WSDL document of http protocol issue with Web Service.
Need to prove, after the WSDL document was connected, if connect unusually, then explanation did not connect the WSDL document, and then judged that current Web Service service is unavailable, if connection procedure does not occur unusually then this locality is read and be cached to the WSDL document.
When Web Service passed through HTTPS protocol issuance WSDL document, the flow chart that the application resource connecting object that the embodiment of the present application provides is connected with the WSDL document of Web Service issue comprised as shown in Figure 3:
Step S301: obtain Web Service by the address of the WSDL document of HTTPS protocol issuance;
Step S302: the HTTPS resource connecting object that creates above-mentioned WSDL address of document;
Step S303: use above-mentioned HTTP S resource connecting object and be connected by the WSDL document of HTTPS protocol issuance with Web Service.
Above step be need to prove: the HTTPS resource connecting object that creates the WSDL address of document, before this HTTPS resource connecting object is operated, first must (Secure Socket Layer SSL be a kind of security protocol that safety and data integrity are provided for network service to SSL.SSL is encrypted network connection in transport layer) context environmental, otherwise, can't use HTTPS protocol resource connecting object to be connected with the WSDL document, after the SSL context environmental carried out initialization, can use HTTPS protocol resource connecting object to be connected with the WSDL document, if connection procedure occurs unusual, then explanation does not connect the WSDL document, and then judge that current Web Service service is unavailable, if connection procedure does not occur unusually then this locality is read and be cached to the WSDL document.
By above discussion as can be known, when can when the WSDL document is connected, the WSDL document on connecting is read, and buffer memory being to home server;
Use the API of JAXP (Java API for XML Processing) to search { " address " } element from the WSDL document, the value of this element is the address of Web Service issue, creates the resource connecting object of this address; The published method of above-mentioned Web Service address has two kinds, and a kind of Web of being Service issues by http protocol, and another kind is that Web Service is by the HTTPS protocol issuance;
When address that the value of above-mentioned element is Web Service by the HTTP issue, the flow chart that the application resource connecting object that the embodiment of the present application provides is connected with Web Service comprises as shown in Figure 4:
Step S401: search the Web Service of appointment in the WSDL document by the Web Service address of service of http protocol issue;
Step S402: the HTTP resource connecting object that creates above-mentioned address of service;
Step S403: the HTTP resource connecting object of using above-mentioned establishment is connected with Web Service.
When address that the value of above-mentioned element is Web Service by the HTTPS issue, the flow chart that the application resource connecting object that the embodiment of the present application provides is connected with Web Service comprises as shown in Figure 5:
Step S501: search the Web Service of appointment in the WSDL document by the Web Service address of service of HTTPS protocol issuance;
Step S502: the HTTPS resource connecting object that creates above-mentioned address of service;
Step S503: use above-mentioned HTTP S resource connecting object and be connected with Web Service.
Need to be to what above step described:
Above step be need to prove: the HTTPS resource connecting object that creates Web Service address, before this HTTPS resource connecting object is operated, first must be to the SSL context environmental, otherwise, can't use HTTPS protocol resource connecting object to be connected with the WSDL document, after the SSL context environmental carried out initialization, can use HTTPS protocol resource connecting object to be connected with the WSDL document.
Tracking detection to Web Servcie availability is the process of a poll, if the application in the OSGi environment has dependence to a Web Service, then will follow the tracks of detection to this Web Service availability at set intervals, when the result of this detection of a Web Service is unavailable, and but the detection of last time is the time spent, the user Web Service of notification service now unavailable.
One detailed structure schematic diagram of a kind of Web Service availability tracing and detecting apparatus that present application example provides comprises as shown in Figure 6: the first address acquisition unit 601, first resource connecting object creating unit 602, the first linkage unit 603, the second address acquisition unit 604, Secondary resource connecting object creating unit 605 and the second linkage unit 606;
Wherein: the first address acquisition unit 601 is used for obtaining the address of WSDL (Web Services Description Language is that a kind of being used for described Web service and the XML language of how to communicate by letter with the Web service is described) document of Web Service issue;
First resource connecting object creating unit 602 creates the resource connecting object of described address of document for the address of the document that obtains according to the first address acquisition unit 601;
The first linkage unit 603 connects creating unit 602 establishments for the application first resource resource connecting object is connected with the WSDL document of Web Service issue, if connection is unusually, then Web Service service is unavailable, otherwise, obtain described WSDL document;
The second address acquisition unit 604 is used for searching the Web Service address of service of the WSDL document appointment that the first linkage unit 603 obtains;
Secondary resource connecting object creating unit 605 is used for creating according to the address of service that the second address acquisition unit 604 is searched the resource connecting object of described address of service;
The resource connecting object that the second linkage unit 606 is used for 605 establishments of application Secondary resource connecting object creating unit is connected with Web Service, if connect unusually, then Web Service service is unavailable, otherwise Web Service serves available.
Apply for the another detailed structure schematic diagram of a kind of Web Service availability tracing and detecting apparatus that embodiment provides as shown in Figure 7, first resource connecting object creating unit 602 comprises: a HTTP resource object creates assembly 607 and a HTTPS resource object creates assembly 608;
Wherein: a HTTP resource object creates assembly 607 and is used for creating Web Service by the HTTP resource connecting object of the address of the WSDL document of http protocol issue;
The one HTTPS resource object creates assembly 608 and is used for creating Web Service by the HTTPS resource connecting object of the address of the WSDL document of HTTPS protocol issuance.
The another detailed structure schematic diagram of a kind of Web Service availability tracing and detecting apparatus that the embodiment of the present application provides as shown in Figure 8, Secondary resource connecting object creating unit 605 comprises: the 2nd HTTP resource object creates assembly 609 and the 2nd HTTPS resource object creates assembly 610;
The 2nd HTTP resource object creates assembly 609 and is used for creating Web Service by the HTTP resource connecting object of the address of service of http protocol issue;
The 2nd HTTPS resource object creates assembly 610 and is used for creating Web Service by the HTTPS resource connecting object of the address of service of HTTPS protocol issuance.
The structural representation of a kind of Web Service availability tracking detection system that application embodiment provides comprises: client 701, a kind of Web Service availability tracing and detecting apparatus 702 and application end 703 as shown in Figure 9;
Wherein: but client 701 is used to the client that operating platform is provided;
Web Service availability tracing and detecting apparatus 702 is used for according to user instruction the availability of Web Service being followed the tracks of testing process and controls;
Application end 703 is used for that Web Service availability is followed the tracks of testing process and specializes implementation and operation.
Each embodiment in this specification all adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses is difference with other embodiment.The above only is the application's embodiment; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the application's principle; can also make some improvements and modifications, these improvements and modifications also should be considered as the application's protection range.