Consuming data from an external web service, how to instantiate the classes after the "import" of the WSDL?

Asked

Viewed 914 times

1

I have no knowledge in WEB-SERVICES, this being the first time I’m using.

After a lot of research I was able to "import" the WSDL file into java and with it "map" all classes of the Web-Service, but it created me many classes and now I don’t know which to use.

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

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

List_products

How I can list these products?

Classes I have relating to 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 you can tell me how to do it? That is, it is usually Generic or depends on the implementation of each WSDL?

2 answers

0


My big doubt was how to instantiate the class, and then I’d be like this:

RealtimeWebServicePortType ws = new RealtimeWebService_Impl().getRealtimeWebServicePort();
ws.lista_linhas();

0

It depends on how you translate the WSDL definitions. Using wsimport, it is very common for several classes to be generated, don’t worry about it, each class equals an important wsdl structure that was generated by PHP.

To use the services, you must instantiate the class you inherit 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.

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

Remember to treat the possible exceptions that may arise when getting the connection, it is common that the service is unavailable and this can cause errors in your application.

  • No, so it doesn’t work, certainly due to the way it was built the WSDL, but fortunately I have already solved the problem, however thank you the same.

  • Yes, I have already implemented a service in Nusoap and I consumed it in java this way. The error that gave to you may have been for other reasons. Perhaps the generated WSDL is from an older SOAP specification (changes according to the version of nusoap), etc... I can’t comment on your comment without knowing, specifically, what the problem was.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.