0

I'm having a problem when using multiple servers in java ws.

All of this servers provide the same WebService but they have different names and IPs.

I'm using UDDI.

My goal is for the client to contact all the servers that are executing that service when performing a request.

Should I do this through a handler or is there another way?

    SDStore port =service.getSDStoreImplPort();

    String uddiURL = args[0];
    String name = args[1];
    Integer nrRep = Integer.parseInt(args[2]);

    System.out.printf("Contacting UDDI at %s%n", uddiURL);
    UDDINaming uddiNaming = new UDDINaming(uddiURL);

    System.out.printf("Looking for '%s'%n", name);
    Vector<String> repsAdd = new Vector<String>(); 
    for(;nrRep>=1;nrRep--){
        repsAdd.add(uddiNaming.lookup(name + nrRep));
        System.out.printf(name+nrRep);
    }
    uddiNaming.lookup(name);

            System.out.println("Creating stub ...");
    // ...

    System.out.println("Setting endpoint address ...");
    BindingProvider bindingProvider = (BindingProvider) port;
    Map<String, Object> requestContext = bindingProvider.getRequestContext();
    requestContext.put(ENDPOINT_ADDRESS_PROPERTY, repsAdd.elementAt(0));

    // Start Store
    StoreM g = new StoreM(port);

I know that through the port instruction I get the interface for this service, but how can I configure the requestContext?

I assume this is what I need to change...

user2934164
  • 193
  • 12

1 Answers1

0

You'll want to get the endPoint value from /business[]/service[]/bindingTemplate[]/accessPoint/endPoint for all services that implement the same interface. Then just loop through the collection calling the JAXWS api,

((BindingProvider)port).getRequestContext().put(ENDPOINT_ADDRESS_PROPERTY, endPoint);

Keep in mind that UDDI also uses redirection so you want want to handle those cases. JUDDI has a helper function to support this kind of resolution (not sure what UDDI library you're using but it doesn't look like JUDDI).

https://svn.apache.org/repos/asf/juddi/trunk/juddi-rest-cxf/src/main/java/org/apache/juddi/api/impl/rest/UDDIInquiryJAXRS.java

search for GetEndpoints. The logic should be simple to transfer.

spy
  • 3,199
  • 1
  • 18
  • 26