org.switchyard.component.soap.InboundHandler Maven / Gradle / Ivy
/*
* JBoss, Home of Professional Open Source
* Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.switchyard.component.soap;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.wsdl.Operation;
import javax.wsdl.Part;
import javax.wsdl.Port;
import javax.wsdl.WSDLException;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Endpoint;
import org.apache.log4j.Logger;
import org.switchyard.Exchange;
import org.switchyard.ExchangeState;
import org.switchyard.HandlerException;
import org.switchyard.Message;
import org.switchyard.Scope;
import org.switchyard.ServiceDomain;
import org.switchyard.ServiceReference;
import org.switchyard.SynchronousInOutHandler;
import org.switchyard.component.soap.composer.SOAPComposition;
import org.switchyard.component.soap.config.model.SOAPBindingModel;
import org.switchyard.component.soap.util.SOAPUtil;
import org.switchyard.component.soap.util.WSDLUtil;
import org.switchyard.composer.MessageComposer;
import org.switchyard.deploy.BaseServiceHandler;
import org.switchyard.exception.DeliveryException;
import org.w3c.dom.Node;
/**
* Hanldes SOAP requests to invoke a SwitchYard service.
*
* @author Magesh Kumar B (C) 2011 Red Hat Inc.
*/
public class InboundHandler extends BaseServiceHandler {
private static final Logger LOGGER = Logger.getLogger(InboundHandler.class);
private static final long DEFAULT_TIMEOUT = 15000;
private static final String MESSAGE_NAME = "MESSAGE_NAME";
private static final String WSDL_LOCATION = "javax.xml.ws.wsdl.description";
private final SOAPBindingModel _config;
private final MessageComposer _messageComposer;
private ServiceDomain _domain;
private ServiceReference _service;
private long _waitTimeout = DEFAULT_TIMEOUT; // default of 15 seconds
private Endpoint _endpoint;
private Port _wsdlPort;
private String _scheme = "http";
/**
* Constructor.
* @param config the configuration settings
* @param domain the service domain
*/
public InboundHandler(final SOAPBindingModel config, ServiceDomain domain) {
_config = config;
_domain = domain;
_messageComposer = SOAPComposition.getMessageComposer(config);
}
/**
* Start lifecycle.
* @throws WebServicePublishException If unable to publish the endpoint
*/
public void start() throws WebServicePublishException {
ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
try {
_service = _domain.getServiceReference(_config.getServiceName());
PortName portName = _config.getPort();
javax.wsdl.Service wsdlService = WSDLUtil.getService(_config.getWsdl(), portName);
_wsdlPort = WSDLUtil.getPort(wsdlService, portName);
// Update the portName
portName.setServiceQName(wsdlService.getQName());
portName.setName(_wsdlPort.getName());
BaseWebService wsProvider = new BaseWebService();
wsProvider.setInvocationClassLoader(Thread.currentThread().getContextClassLoader());
// Hook the handler
wsProvider.setConsumer(this);
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy