/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: SOAPClient.java,v 1.9 2008/09/03 07:06:30 lakshman_abburi Exp $
*
*/
/**
* Portions Copyrighted 2011-2012 ForgeRock Inc
*/
/**
* The class <code>SOAPClient</code> provides methods for SOAP and JAXRPC
* client to send and receive messages. The method <code>call(..)</code> will
* be used by SOAP client to send SOAP messages, and JAXRPC clients will use
* <code>encodeMessage</code> and <code>send</code> to send JAXRPC requests.
* The method <code>encodeMessage(String functionName,
* Object[] args)</code>,
* encodes the JAXRPC data in SOAP, which can then be sent using the <code>send(
* String message, String cookies)</code>.
* <p>
* The <code>SOAPClient</code> can be initialized either with known SOAP
* endpoint URLs or it will find an active server using Naming service. In the
* case of JAXRPC, the SOAP response is decoded and returns a java
* <code>Object</code>; else an exception is thrown.
*
* @deprecated As of OpenSSO version 8.0
* {@link com.sun.identity.shared.jaxrpc.SOAPClient}
*/
public class SOAPClient {
// Debug file
// Instance variables
// Variables for direct URLs
// Variables for managing exceptions
int ldapErrorCode;
boolean isException;
/**
* Constructor for applications that would like to dynamically set the SOAP
* endponts using <code>
* <code>setUrls(String[] urls)</code> before
* invoking either <code>send()</code> or <code>
* call()</code>.
*/
// do nothing
}
/**
* Constructor for services that use JAXRPC as their communication protocol.
* The URL end points for these services will be obtained from Naming
* service for jaxrpc service, and the service name will appended to it as
* the JAXRPC interface name.
*/
this.serviceName = serviceName;
}
/**
* Constructor for applications that have the list of end point URLs. The
* <code>SOAPClient</code> will iterate through the URLs in case of server
* failure.
*/
}
/**
* Performs a raw SOAP call with "message" as the SOAP data and response is
* returned as <code>StringBuffer</code>
*/
if (debug.messageEnabled()) {
}
// Setup the connection, support for failover
boolean done = false;
int urlIndex = 0;
while (!done) {
// Check for a valid URL, if not find one
// Check if URLs are provided at the time of
// constructor, else get it from JAXRPCUtils
// All the URLs have been checked
// throw RemoteException
if (debug.warningEnabled()) {
}
throw (new RemoteException("no-server-found"));
}
} else {
// This function throws RemoteException
// if no servers are found
}
}
connection.setDoOutput(true);
}
}
// Output
try {
} catch (ConnectException ce) {
// Debug the exception
if (debug.warningEnabled()) {
ce);
}
// Server may be down, try the next server
continue;
}
// Write out the message
// Get the response
try {
} catch (IOException ioe) {
// Could be receiving SOAP fault
// Debug the exception
if (debug.messageEnabled()) {
}
isException = true; // Used by send(...)
} finally {
done = true;
}
}
if (debug.messageEnabled()) {
in_buf, "UTF-8"));
}
+ data);
}
return (in_buf);
}
/**
* Performs a JAXRPC method call. The parameter <code>
* functionName</code>
* is the JAXRPC function to be called with parameters <code>params</code>.
* Returns an object on success, else throws an <code>Exception
* </code>.
*/
}
/**
* Performs a JAXRPC method call. The parameter <code>
* functionName</code>
* is the JAXRPC function to be called with parameter <code>param</code>.
* Returns an object on success, else throws an <code>Exception
* </code>.
*/
}
/**
* Performs a JAXRPC method call. The parameter <code>
* message</code>
* contains SOAP encoded function call obtained from
* <code>encodeMessage</code>. Returns an object on success, else throws
* an <code>Exception
* </code>.
*/
throws Exception {
// Initialize variables
messageArgs = null;
errorString = null;
ldapErrorCode = 0;
isException = false;
// Send the SOAP request and get the response
// Decode the output. Parse the document using SAX
try {
if (debug.warningEnabled()) {
} else {
}
} catch (ParserConfigurationException pce) {
if (debug.warningEnabled()) {
}
} catch (SAXException saxe) {
if (debug.warningEnabled()) {
}
}
// Check for exceptions
if (isException) {
throw (exception);
}
}
}
}
}
}
return (encodeInt("int_1", i));
}
}
return (encodeBoolean("boolean_1", b));
}
// Make string to be XML compliant
}
}
}
}
}
}
}
}
return (null);
}
} else if (value instanceof byte[][]) {
}
}
}
return (Collections.EMPTY_MAP);
}
// Add prefix and suffix to the xmlMap
try {
.getBytes("UTF-8"))));
} catch (Exception e) {
if (debug.warningEnabled()) {
}
return (Collections.EMPTY_MAP);
}
}
/**
* Returns a SOAP request compliant with JAXRPC for the provide function
* name <code>function</code> that takes the parameter <code>param</code>
* as the only argument.
*/
}
}
/**
* Returns a SOAP request compliant with JAXRPC for the provide function
* name <code>function</code> that takes the parameters
* <code>params</code> as its arguments.
*/
int index = 1;
" xmlns:ans1=\"http://isp.com/wsdl\">");
index++;
} else {
}
}
}
boolean started;
protected SOAPContentHandler() {
types = new LinkedList();
maps = new LinkedList();
keys = new LinkedList();
}
}
started = true;
return;
}
if (!isException) {
// Determine the object type
}
// Get the type, could be String, Set or MapEntry
currentSet = new OrderedSet();
currentList = new LinkedList();
}
}
} else {
// Check for ArrayOfanyType and reset the set
messageArgs = new HashSet();
}
}
// Initialize currentString
if (currentString == null) {
currentString = new StringBuffer();
}
}
// Determine the current type and copy elements to answer
if (!started) {
return;
}
// Process results if exception is not returned
if (!isException) {
// End of an item
if (currentSet != null) {
} else {
}
}
.equalsIgnoreCase(MAPENTRY)) {
}
// End if key value for Map
// End of results
try {
} catch (NumberFormatException nfe) {
}
}
}
} else {
// Exception was thrown
}
}
}
}
// Set currentString to null
}
throws SAXException {
}
return (answer);
}
// Ignore
}
// If exception is thrown, construct the exception
if (isException) {
if (resourceBundleName != null) {
} else if (exceptionMessage != null) {
} else {
}
if (resourceBundleName != null) {
: messageArgs.toArray());
} else if (exceptionMessage != null
&& exceptionCode != null) {
try {
} catch (NumberFormatException nfe) {
// Ignore
}
} else if (smsExceptionCode != null) {
try {
} catch (NumberFormatException nfe) {
// Ignore
}
} else if (exceptionMessage != null) {
} else {
// Throw generic SMSException
exception = new SMSException();
}
if (resourceBundleName != null) {
exception = new IdRepoException(
messageArgs.toArray());
} else if (exceptionCode != null) {
} else if (exceptionMessage != null) {
} else {
// Throw generic SMSException
exception = new SMSException();
}
if (messageArgs != null) {
} else {
}
if (exceptionMessage != null) {
} else {
}
} else {
// Catch all for remaing exception
if (exceptionMessage != null) {
} else {
}
}
}
}
throws SAXException {
// Ignore
}
// Ignore
}
// Ignore
}
throws SAXException {
// Ignore white spaces
}
// Ignore skipped entry
}
}
SOAPErrorHandler() {
// do nothing
}
}
// do nothing, error can be ignored
}
// Parser warning can be ignored
}
}
// Static variables
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" "
+ "xmlns:ns0=\"http://isp.com/types\" "
+ "xmlns:ns1=\"http://java.sun.com/jax-rpc-ri/internal\" "
+ "env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">";
"com.iplanet.am.sdk.remote.AMRemoteException";
"com.sun.identity.sm.IdRepoException";
"com.sun.identity.entity.EntityException";
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" "
+ "xmlns:ns0=\"http://isp.com/types\" "
+ "xmlns:ns1=\"http://java.sun.com/jax-rpc-ri/internal\" "
+ "env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ "<env:Body><ans1:readResponse xmlns:ans1=\"http://isp.com/wsdl\">";
"</ans1:readResponse></env:Body></env:Envelope>";
}