Code Example for WS Call (SAP NetWeaver Developer
Studio)
In the following code example, the Web Service for a communication party is called using a Java proxy that was generated in the SAP NetWeaver Developer Studio.
CommunicationPartyService partyService = new CommunicationPartyServiceImpl();
CommunicationPartyServiceViDocument vi = partyService.getLogicalPort();
// set the timeout for the web service call
BaseGeneratedStub stub = (BaseGeneratedStub) vi;
stub._setProperty("socketTimeout", "30000");
// set basic authentication user name and password
SecurityProtocol securityProtocol = (SecurityProtocol) stub._getGlobalProtocols().getProtocol("SecurityProtocol");
AuthenticationContext authenticationContext = securityProtocol.getAuthenticationContext();
authenticationContext.setUsername("userName");
authenticationContext.setPassword("userPassword");
// set the login language
securityProtocol.addHeader("Accept-Language", "en");
Prerequisite for this call is that you must have generated a Java proxy on the J2EE Engine.

For more information, see Web Services.

Note the timeout that is set in the code example. Because the Web Service calls can take longer when using the programming interface, you must ensure not to set the timeout too short.