org.openspml.v2.client
Class Spml2Client

java.lang.Object
  extended byorg.openspml.v2.client.Spml2Client

public class Spml2Client
extends java.lang.Object

A class providing a mechanism to send and recieve SPML2 requests using the Spml2Request and Spml2Response classes.

Once the request is formatted as XML, it uses the SOAPClient class to handle the actual communication. When the XML response is received, it is parsed into a Spml2Response and returned.


Nested Class Summary
static interface Spml2Client.SOAPClientAdapter
          We define one of these so we have a chance of using different Soap Client implementations.
 
Field Summary
static java.lang.String code_id
           
 
Constructor Summary
Spml2Client(java.lang.String url)
           
Spml2Client(java.lang.String url, java.lang.String username, java.lang.String pwd)
           
 
Method Summary
static void println(java.lang.String msg)
           
 Response send(Request req)
          Send an XmlObject as the body of a SOAP request.
 java.lang.String send(java.lang.String xml)
          Send xml as a payload and return the entire SOAPResponse.
 java.lang.String sendRequest(Request req)
          Take an object and return the entire SOAP response as xml.
 void setBodyAttributes(java.lang.String s)
          Set an optional list of attributes for the SOAP Body.
 void setHeader(java.lang.String s)
          Set an optional SOAP Header.
 void setMonitor(RPCRouterMonitor m)
          Install a SOAP message monitor.
 void setSOAPAction(java.lang.String action)
          Use this action in the SOAPClient.
 void setTrace(boolean b)
           
 void throwErrors(Response res)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

Spml2Client

public Spml2Client(java.lang.String url)
            throws Spml2Exception

Spml2Client

public Spml2Client(java.lang.String url,
                   java.lang.String username,
                   java.lang.String pwd)
            throws Spml2Exception
Method Detail

setHeader

public void setHeader(java.lang.String s)
Set an optional SOAP Header. The string is expected to contain well formed XML.


setSOAPAction

public void setSOAPAction(java.lang.String action)
Use this action in the SOAPClient.

Parameters:
action -

setBodyAttributes

public void setBodyAttributes(java.lang.String s)
Set an optional list of attributes for the SOAP Body. The string is expected to contain a fragment of well formed XML attribute definitions, "wsu:Id='myBody'" It is assumed for now that any namespace references in the attribute names do not need to be formally declared in the soap:Envelope.


setTrace

public void setTrace(boolean b)

setMonitor

public void setMonitor(RPCRouterMonitor m)
Install a SOAP message monitor.


send

public Response send(Request req)
              throws Spml2Exception,
                     Spml2ExceptionWithResponse
Send an XmlObject as the body of a SOAP request.

We use an XmlObject because XmlBeans makes it rather difficult to use anything else (to narrow the type to a particular type in the schema.) You should be passing instances of the 'RequestType' enclosing 'Document' objects, e.g. ListTargetsDocument and AddRequestDocument. (These do NOT have a common base class, and using RequestType sub-interfaces makes for odd tricks... like seeting a requesttype to a Document...)

Not accounting for SOAP faults...

Parameters:
req - An XmlOBject (*Document interface) that is the body of the request.
Returns:
one of the *ResponseDocument types from the xmlbeans bindings.
Throws:
Spml2Exception
Spml2ExceptionWithResponse

sendRequest

public java.lang.String sendRequest(Request req)
                             throws Spml2Exception
Take an object and return the entire SOAP response as xml.

Parameters:
req -
Returns:
SOAP (xml string)
Throws:
Spml2Exception

send

public java.lang.String send(java.lang.String xml)
                      throws Spml2Exception
Send xml as a payload and return the entire SOAPResponse. Not accounting for SOAP faults, caller must parse the response.

Parameters:
xml -
Returns:
The raw SOAP response. (Envelope and Body still there.)
Throws:
Spml2Exception

println

public static void println(java.lang.String msg)

throwErrors

public void throwErrors(Response res)
                 throws Spml2ExceptionWithResponse
Throws:
Spml2ExceptionWithResponse


Copyright © Sun Microsystems, Inc. All Rights Reserved.