1 | package gov.hhs.fha.nhinc.wsdlissue.sample;
|
---|
2 |
|
---|
3 | import javax.xml.ws.BindingProvider;
|
---|
4 | import org.uddi.api_v3.BusinessList;
|
---|
5 | import org.uddi.api_v3.FindBusiness;
|
---|
6 | import org.uddi.v3_service.UDDIService;
|
---|
7 | import org.uddi.v3_service.UDDIInquiryPortType;
|
---|
8 |
|
---|
9 |
|
---|
10 | /**
|
---|
11 | *
|
---|
12 | * @author westbergl
|
---|
13 | */
|
---|
14 | public class SampleServiceHelper extends Thread
|
---|
15 | {
|
---|
16 | // URL for the UDDI Server.
|
---|
17 | private static String m_sUDDIInquiryEndpointURL = "http://12.54.145.57:8080/uddi/services/inquiry";
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * This method retrieves the port for the UDDI server with the correct endpoint.
|
---|
21 | *
|
---|
22 | * @return
|
---|
23 | */
|
---|
24 | private static UDDIInquiryPortType getUDDIInquiryWebService()
|
---|
25 | throws Exception
|
---|
26 | {
|
---|
27 | UDDIInquiryPortType oPort = null;
|
---|
28 |
|
---|
29 | try
|
---|
30 | {
|
---|
31 | UDDIService oService = new UDDIService();
|
---|
32 | oPort = oService.getUDDIInquiryPort();
|
---|
33 |
|
---|
34 | // Need to load in the correct UDDI endpoint URL address.
|
---|
35 | //--------------------------------------------------------
|
---|
36 | ((BindingProvider)oPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, m_sUDDIInquiryEndpointURL);
|
---|
37 | }
|
---|
38 | catch (Exception e)
|
---|
39 | {
|
---|
40 | String sErrorMessage = "Failed to retrieve the UDDI Inquiry Web Service port. Error: " + e.getMessage();
|
---|
41 | System.out.println(sErrorMessage);
|
---|
42 | throw new Exception(sErrorMessage, e);
|
---|
43 | }
|
---|
44 |
|
---|
45 | return oPort;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * This method retrieves the business entities from the UDDI server.
|
---|
50 | * It does not retrieve the services or bindings. They are retrieved
|
---|
51 | * on other calls. This only retrieves the business information.
|
---|
52 | *
|
---|
53 | * @return the BusinessEntities retrieved from the UDDI server.
|
---|
54 | * @throws Exception
|
---|
55 | */
|
---|
56 | private static void retrieveBusinessesInfoFromUDDI()
|
---|
57 | throws Exception
|
---|
58 | {
|
---|
59 | System.out.println("Retrieving business entities from UDDI using find_business web service call.");
|
---|
60 |
|
---|
61 | BusinessList oBusinessList = null;
|
---|
62 |
|
---|
63 | try
|
---|
64 | {
|
---|
65 | UDDIInquiryPortType oPort = getUDDIInquiryWebService();
|
---|
66 |
|
---|
67 | // Make the call...
|
---|
68 | //-----------------
|
---|
69 | FindBusiness oSearchParams = new FindBusiness();
|
---|
70 | oSearchParams.setMaxRows(100);
|
---|
71 | oBusinessList = oPort.findBusiness(oSearchParams);
|
---|
72 |
|
---|
73 | }
|
---|
74 | catch (Exception e)
|
---|
75 | {
|
---|
76 | String sErrorMessage = "Failed to call 'find_business' web service on the NHIN UDDI server. Errror: " +
|
---|
77 | e.getMessage();
|
---|
78 | System.out.println(sErrorMessage);
|
---|
79 | throw new Exception(sErrorMessage, e);
|
---|
80 | }
|
---|
81 |
|
---|
82 | }
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * This method is used to retrieve the data from the UDDI server. The
|
---|
86 | * data is returned in the form of CMBusinessEntities.
|
---|
87 | *
|
---|
88 | *
|
---|
89 | * @throws Exception
|
---|
90 | */
|
---|
91 | public static void retrieveFromUDDIServer()
|
---|
92 | throws Exception
|
---|
93 | {
|
---|
94 | // Retrieve the high level business information...
|
---|
95 | //-----------------------------------------------
|
---|
96 | retrieveBusinessesInfoFromUDDI();
|
---|
97 | }
|
---|
98 |
|
---|
99 | @Override
|
---|
100 | public void run()
|
---|
101 | {
|
---|
102 | try
|
---|
103 | {
|
---|
104 | retrieveFromUDDIServer();
|
---|
105 | }
|
---|
106 | catch (Exception e)
|
---|
107 | {
|
---|
108 | System.out.println("Run Method: Unexpected Exception: " + e.getMessage());
|
---|
109 | e.printStackTrace();
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | public static void main (String[] args)
|
---|
114 | {
|
---|
115 | System.out.println("Starting test.");
|
---|
116 | try
|
---|
117 | {
|
---|
118 | retrieveFromUDDIServer();
|
---|
119 | }
|
---|
120 | catch (Exception e)
|
---|
121 | {
|
---|
122 | System.out.println("Unexpected error occurred: " + e.getMessage());
|
---|
123 | e.printStackTrace();
|
---|
124 | System.exit(-1);
|
---|
125 | }
|
---|
126 | System.out.println("End of test.");
|
---|
127 | }
|
---|
128 |
|
---|
129 | }
|
---|