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