A dynamic Web Service call holds all relevant information in one file, the client, which Axis converts directly into the SOAP message. Essentially, the client you create is a Java version of the call itself, excluding some relative values that are replaced with absolute ones at compile time.
Keep in mind that if you want to access a Web Service that uses non-standard data types, you need to create your Web Service call following the static process. See Creating a Call Using a Client Stub (Static).
If you want to enable Web Services to share sessions, your code needs to pass cookies between calls. The following example, which creates a dynamic Web Service call to the loginUser
Web Service, uses the CookieContainer
class shown in Writing a CookieContainer Class:
Service service = new Service(); Call call = (Call) service.createCall(); // Get a hold of a CookieContainer passed to this method/class CookieContainer cookieContainer = new CookieContainer(); // Push previous cookies (if any) to the new Call object cookieContainer.pushCookies(call); call.setMaintainSession(true); call.setTargetEndpointAddress(new java.net.URL("http://hostname
:port
/userprofiling/usersession/loginUser/ loginUser") ); // Don't allow XML elements to reference other XML elements call.setProperty(AxisEngine.PROP_DOMULTIREFS,Boolean.FALSE) call.addParameter("Login", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter("Password", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter("IsPasswordEncrypted", org.apache.axis.Constants.XSD_BOOLEAN, javax.xml.rpc.ParameterMode.IN); call.setReturnType(org.apache.axis.Constants.XSD_STRING); call.setOperationName(new QName("http://www.atg.com/webservices", "loginUser")); String userId = (String) call.invoke( new Object[] { "bhavern", "xyo8bnif", Boolean.FALSE } ); // Extract new cookies from the Call into the CookieContainer object, // which can then be passed to subsequent calls cookieContainer.extractCookies(call); }