Show TOC Anfang des Inhaltsbereichs

Hintergrunddokumentation Code-Beispiel für Web-Service-Aufruf (Web Tools Platform von Eclipse)  Dokument im Navigationsbaum lokalisieren

Mit dem folgenden Beispielcode legen Sie ein einfaches Objekt vom Typ Party (Kommunikationspartner) an. Hierbei verwenden Sie den Web-Service-Client, den Sie mit der Web Tools Platform von Eclipse erzeugt haben.

package CommunicationPartyServiceWsd;

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import demo.types.ConfigurationObjectModifyOut;

import demo.types.PartyCreateChangeIn;

import demo.types.PartyRestricted;

 

public class CallMe {

  public static void main(String[] args) {

    try{

      //Create a new simple Communication Party and set mandatory attributes

      PartyRestricted party = new PartyRestricted();

      party.setMasterLanguage("en");

      party.setPartyID("HelloWorld");

 

      //Create a new instance of request object expected by Communication

      //Party Web Service and set the above created object instance

      PartyCreateChangeIn partyCreateRequest = new PartyCreateChangeIn();    

      partyCreateRequest.setParty(new PartyRestricted[]{party});

     

      //Create a new service instance and fetch the port type instance, ...

      HTTPService service = new HTTPServiceLocator();

      CommunicationPartyServiceVi_Document document = service.getHTTPort();

     

      // ... cast it to a stub instance and set user/password because basic authentication is

      // required by Web Service

      HTTPBindingStub stub =  (HTTPBindingStub) document;

      stub.setUsername("myuser");

      stub.setPassword("mypwd");

     

      //Now call the Web Service and create the HelloWorld Communication Party

      ConfigurationObjectModifyOut response = document.create(partyCreateRequest);

     

      //Do something with the response

      System.out.println( response.toString() );

    } catch (RemoteException ex){

      ex.printStackTrace();     

    } catch (ServiceException e) {

      e.printStackTrace();

    }

  }

}

Ende des Inhaltsbereichs