Consume data from an external web service, such as instantiating the class after the "import" of the WSDL?

1

I do not know anything about WEB-SERVICES , this being the first time I'm using it.

After a lot of research I was able to "import" the WSDL file into java and thus "map" all classes of Web-Service , but this created me many classes and now I do not know which ones to use.

web-service was developed in PHP with NuSOAP , and I think it uses an old technology, something like JAX-RPC STYLE (I had to install the netbeans plugin to get this mapping). >

Now in the web-service I have for example this function:

  

ProductList

How can I list these products?

Classes I have regarding this:

Lista_produtos.java
Lista_produtos_SOAPBUiler.java
Lista_produtos_SOAPserializer.java
RealtimeWebService.java//Penso que são as class principais
RealtimeWebService_Impl.java//Penso que são as class principais
RealtimeWebServicePortType.java
RealtimeWebServicePortTypeLista_produtosRequestStruct.java
RealtimeWebServicePortTypeLista_produtosRequestStruct_SOAPBuiler.java
RealtimeWebServicePortTypeLista_produtosRequestStruct_SOAPSerializer.java

By name can you tell me how to do it? Is this usually generic or does it depend on the implementation of each WSDL?

    
asked by anonymous 24.07.2014 / 14:39

2 answers

0

My biggest question was how to instantiate the class, so it would look like this:

RealtimeWebServicePortType ws = new RealtimeWebService_Impl().getRealtimeWebServicePort();
ws.lista_linhas();
    
24.07.2014 / 16:47
0

Depends on the way you translate the WSDL settings. Using wsimport, it is very common for multiple classes to be generated, so do not worry, each class is equivalent to an important wsdl structure that was generated by PHP.

To use the services, you must instantiate the class that inherits from Service, and then call the method that returns the interface with the methods listed in the service. In your case, it appears to be:

RealtimeWebService_Impl serviceFactory = new RealtimeWebService_Impl();
RealtimeWebService service = serviceFactory.get..Port(); // Algum método que termine com port e, que retorna a interface com os métodos disponibilizados no serviço.

Once you get the service instance, you can call the available services.

Remember to handle any possible exceptions that may arise at the time of connection, it is common that the service is unavailable and this may cause errors in your application.

    
24.07.2014 / 17:18