Search in sources :

Example 1 with SOAPException

use of org.apache.soap.SOAPException in project iaf by ibissource.

the class SoapConfigManager method loadRegistry.

public void loadRegistry() throws SOAPException {
    URL servicesRegistry;
    String message;
    try {
        servicesRegistry = context.getResource(filename);
    } catch (MalformedURLException e) {
        message = "cannot find URL for registry from resource-name '" + filename + "'";
        log.error(message, e);
        throw new SOAPException(Constants.FAULT_CODE_SERVER, message, e);
    }
    if (servicesRegistry == null) {
        message = "cannot find registry from resource-name '" + filename + "'";
        log.error(message);
        throw new SOAPException(Constants.FAULT_CODE_SERVER, message);
    }
    Element element = null;
    try {
        Document document = xdb.parse(servicesRegistry.openStream());
        element = document.getDocumentElement();
    } catch (Exception e) {
        message = "exception while reading servicesRegistry from " + servicesRegistry;
        log.error(message, e);
        throw new SOAPException(Constants.FAULT_CODE_SERVER, message, e);
    }
    log.info("loading servicesRegistry from " + servicesRegistry);
    ;
    NodeList nodelist = element.getElementsByTagNameNS("http://xml.apache.org/xml-soap/deployment", "service");
    int i = nodelist.getLength();
    dds = new Hashtable();
    for (int j = 0; j < i; j++) {
        Element element1 = (Element) nodelist.item(j);
        DeploymentDescriptor deploymentdescriptor = DeploymentDescriptor.fromXML(element1);
        String s = deploymentdescriptor.getID();
        log.info("deploying service " + s);
        dds.put(s, deploymentdescriptor);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Hashtable(java.util.Hashtable) SOAPException(org.apache.soap.SOAPException) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) DeploymentDescriptor(org.apache.soap.server.DeploymentDescriptor) Document(org.w3c.dom.Document) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) SOAPException(org.apache.soap.SOAPException)

Example 2 with SOAPException

use of org.apache.soap.SOAPException in project iaf by ibissource.

the class SoapGenericProvider method invoke.

public void invoke(SOAPContext reqContext, SOAPContext resContext) throws SOAPException {
    try {
        String targetObjectURI = (String) reqContext.getProperty(TARGET_OBJECT_URI_KEY);
        if (log.isDebugEnabled()) {
            log.debug("Invoking service for targetObjectURI=[" + targetObjectURI + "]");
        }
        // String message=soapWrapper.getBody(reqContext.getBodyPart(0).getContent().toString());
        String message = reqContext.getBodyPart(0).getContent().toString();
        HttpServletRequest httpRequest = (HttpServletRequest) reqContext.getProperty(Constants.BAG_HTTPSERVLETREQUEST);
        HttpServletResponse httpResponse = (HttpServletResponse) reqContext.getProperty(Constants.BAG_HTTPSERVLETRESPONSE);
        ISecurityHandler securityHandler = new HttpSecurityHandler(httpRequest);
        Map messageContext = new HashMap();
        messageContext.put(IPipeLineSession.securityHandlerKey, securityHandler);
        messageContext.put("httpListenerServletRequest", httpRequest);
        messageContext.put("httpListenerServletResponse", httpResponse);
        String result = sd.dispatchRequest(targetObjectURI, null, message, messageContext);
        // resContext.setRootPart( soapWrapper.putInEnvelope(result,null), Constants.HEADERVAL_CONTENT_TYPE_UTF8);
        resContext.setRootPart(result, Constants.HEADERVAL_CONTENT_TYPE_UTF8);
    } catch (Exception e) {
        // log.warn("GenericSoapProvider caught exception:",e);
        if (e instanceof SOAPException) {
            throw (SOAPException) e;
        }
        SOAPException se = new SOAPException(Constants.FAULT_CODE_SERVER, "GenericSoapProvider caught exception");
        se.initCause(e);
        throw se;
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ISecurityHandler(nl.nn.adapterframework.core.ISecurityHandler) HashMap(java.util.HashMap) SOAPException(org.apache.soap.SOAPException) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpSecurityHandler(nl.nn.adapterframework.http.HttpSecurityHandler) HashMap(java.util.HashMap) Map(java.util.Map) SOAPException(org.apache.soap.SOAPException)

Example 3 with SOAPException

use of org.apache.soap.SOAPException in project iaf by ibissource.

the class ServiceDispatcher_ServiceProxy method dispatchRequest.

/**
 * Dispatch a request.
 * @param servicename ServiceName
 * @param correlationId CorrelationID
 * @param message Message
 * @return String the result
 * @throws SOAPException
 */
public String dispatchRequest(String servicename, String correlationId, String message) throws SOAPException {
    Call call = new Call();
    call.setTargetObjectURI("urn:service-dispatcher");
    call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/");
    String SOAPActionURI = "urn:service-dispatcher";
    if (url == null) {
        throw new SOAPException(Constants.FAULT_CODE_CLIENT, "A URL must be specified via " + "ServiceDispatcher_ServiceProxy.setEndPoint(URL).");
    }
    call.setMethodName("dispatchRequest");
    Vector params = new Vector();
    params.addElement(new Parameter("meth1_inType1", String.class, servicename, null));
    params.addElement(new Parameter("meth1_inType2", String.class, correlationId, null));
    params.addElement(new Parameter("meth1_inType3", String.class, message, null));
    call.setParams(params);
    Response resp = call.invoke(url, SOAPActionURI);
    // Check the response.
    if (resp.generatedFault()) {
        Fault fault = resp.getFault();
        throw new SOAPException(fault.getFaultCode(), fault.getFaultString());
    } else {
        Parameter retValue = resp.getReturnValue();
        return (String) retValue.getValue();
    }
}
Also used : Response(org.apache.soap.rpc.Response) Call(org.apache.soap.rpc.Call) SOAPException(org.apache.soap.SOAPException) Parameter(org.apache.soap.rpc.Parameter) Fault(org.apache.soap.Fault) Vector(java.util.Vector)

Aggregations

SOAPException (org.apache.soap.SOAPException)3 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 Map (java.util.Map)1 Vector (java.util.Vector)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ISecurityHandler (nl.nn.adapterframework.core.ISecurityHandler)1 HttpSecurityHandler (nl.nn.adapterframework.http.HttpSecurityHandler)1 Fault (org.apache.soap.Fault)1 Call (org.apache.soap.rpc.Call)1 Parameter (org.apache.soap.rpc.Parameter)1 Response (org.apache.soap.rpc.Response)1 DeploymentDescriptor (org.apache.soap.server.DeploymentDescriptor)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1