Web Service Consumer Java Example

Has someone an code example for an agent calling a Web Service Consumer. Written in Java.

(See also my Ticket http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/0e7f596427e1861e852576ad007c7cac?OpenDocument)

Subject: Java agent

here below you can find an example.

import lotus.domino.*;

import it.td.ade.ws.*;

import it.td.ade.beans.Ade;

public class AllAde extends AgentBase {

public void NotesMain() {



		try {

			Document docNew = null;

			AdeSilWSPortType stub = new AdeSilWSLocator().getAdeSilWSHttpSoap11Endpoint();

			Ade[] listOfAde = stub.getAllAde(3,100);

			for(int i = 0; i < listOfAde.length; i++ ){

				docNew = db.createDocument();

				docNew.appendItemValue("Form", "myform");



				if (docNew.save()){

					System.out.println("Document has been saved");

				}else {

					System.out.println("Unable to save document");

				}

			}



		} catch(Exception e){

			e.printStackTrace();

		}

}

}

Whitin the server consumer you will find the interface that you have to use:

/*

  • To instantiate a callable instance for invoking this service, copy and paste from the following:

    import it.td.ade.ws.*;

    // Refer to it.td.ade.ws.AdeSilWSPortType.java for service interface methods:

    AdeSilWSPortType stub = new AdeSilWSLocator().getAdeSilWSHttpSoap11Endpoint();

*/

package it.td.ade.ws;

public interface AdeSilWS extends javax.xml.rpc.Service {

public java.lang.String getAdeSilWSHttpSoap11EndpointAddress();



public it.td.ade.ws.AdeSilWSPortType getAdeSilWSHttpSoap11Endpoint() throws javax.xml.rpc.ServiceException;



public it.td.ade.ws.AdeSilWSPortType getAdeSilWSHttpSoap11Endpoint(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;

}

Subject: … but still no success

Thanks a lot. But for me it still does not work.

Your agent code has only 2 lines for web service. Why do you mention the instantiation of the interface. The 3 methods are automatically generated in the stub class.(?)

In my case, when creating a web consumer 2 inderfaces and 2 classes are generated. I think they are ready to use or do I have to code?

Why is my example ony working in lotus script? May you have look:

http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/0e7f596427e1861e852576ad007c7cac?OpenDocument

Thank you so much.

Subject: Found it

The line to copy from is collapsed in Domino Designer! That is why I did not see it!

/*

  • To instantiate a callable instance for invoking this service, copy and paste from the following:

import it.td.ade.ws.*;

// Refer to it.td.ade.ws.AdeSilWSPortType.java for service interface methods:

AdeSilWSPortType stub = new AdeSilWSLocator().getAdeSilWSHttpSoap11Endpoint();

*/

Java Web Service Consumers for dummies:

  1. Have WSDL File ready

  2. New Web Service Consumer.

  3. After wizard 2 interfaces and 2 implementation classes are created. They usually contain everything you need.

  4. Create Java agent to consume the Web Service Consumer.

  5. Instantiate using the line from the service interface (i.e. AdeSilWSPortType stub = new AdeSilWSLocator().getAdeSilWSHttpSoap11Endpoint();

)

Subject: Java agent

Good, well done.

http://www-10.lotus.com/ldd/nd85forum.nsf/ShowMyTopicsAllFlatweb/a1292f0bf67c6dbf852576b0003d2485?OpenDocument