Author: objectiser
Date: 2010-11-16 08:36:29 -0500 (Tue, 16 Nov 2010)
New Revision: 1107
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ODEWebServiceFactory.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/
trunk/runtime/engine/src/main/java/org/jboss/soa/si/InvocationAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ServiceInvoker.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/BaseWebServiceEndpoint.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/DOMWriter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/JavaUtils.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/TemplateWebServiceEndpoint.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLParser.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLReference.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceDetails.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceFactory.java
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceProviderFactory.java
Removed:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DOMWriter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLParser.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLReference.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java
Modified:
trunk/integration-tests/pom.xml
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/BPELEngine.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLHelper.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java
trunk/runtime/engine/src/test/java/riftsaw124/Riftsaw124TestCase.java
trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/internal/soa/esb/actions/bpel/ESBInvocationAdapter.java
trunk/runtime/jbossesb-bpel/src/test/java/org/jboss/soa/esb/actions/bpel/TestBPELEngine.java
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java
Log:
Starting refactor to extract the service provider mechanism, specifically the web service
endpoint provider generation.
Modified: trunk/integration-tests/pom.xml
===================================================================
--- trunk/integration-tests/pom.xml 2010-11-15 11:59:30 UTC (rev 1106)
+++ trunk/integration-tests/pom.xml 2010-11-16 13:36:29 UTC (rev 1107)
@@ -585,6 +585,9 @@
<includes>
<include>**/*TestCase.java</include>
<include>**/*Test.java</include>
+ <!--
+ <include>org/jboss/soa/bpel/tests/samples/QuickstartBPELHelloWorldTestCase.java</include>
+ -->
</includes>
<!--
https://jira.jboss.org/jira/browse/RIFTSAW-34 -->
<excludes>
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/BPELEngine.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/BPELEngine.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/BPELEngine.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -17,6 +17,9 @@
*/
package org.jboss.soa.bpel.runtime.engine;
+import org.jboss.soa.si.InvocationAdapter;
+import org.jboss.soa.si.ServiceInvoker;
+
/**
* This interface represents a BPEL engine.
*
@@ -24,7 +27,7 @@
* @author Heiko Braun
*
*/
-public interface BPELEngine {
+public interface BPELEngine extends ServiceInvoker {
public static final String Service="bpel/Engine";
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.soa.bpel.runtime.engine;
-
-import org.apache.ode.bpel.iapi.Message;
-import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
-
-import javax.xml.namespace.QName;
-
-/**
- * Hides the message translation details when invoking ODE from
- * an external component (i.e. ESB or WS).
- *
- * @see org.jboss.soa.bpel.runtime.engine.BPELEngine#invoke(InvocationAdapter)
- *
- * @author Heiko Braun <hbraun(a)redhat.com>
- */
-public interface InvocationAdapter<T>
-{
- String getOperationName();
- QName getServiceName();
- String getPortName();
-
- /**
- * Callback from the Engine towards the adapter when
- * turning an external message representation into an ODE request {@link
org.apache.ode.bpel.iapi.Message}
- * @param mex
- * @param odeRequest
- */
- void parseRequest(MyRoleMessageExchange mex, Message odeRequest);
-
- /**
- * Callback from the Engine towards the adapter when
- * turning an ODE response {@link org.apache.ode.bpel.iapi.Message} into an external
format <T>
- * @param mex
- */
- void createResponse(MyRoleMessageExchange mex);
-
- void createFault(MyRoleMessageExchange mex);
- /**
- * Access the invocation result (response)
- * @return T
- */
- T getInvocationResult();
-
-}
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -41,8 +41,8 @@
import org.apache.ode.utils.GUID;
import org.apache.ode.utils.Properties;
import org.jboss.soa.bpel.runtime.engine.BPELEngine;
-import org.jboss.soa.bpel.runtime.engine.InvocationAdapter;
import org.jboss.soa.bpel.runtime.integration.ServerConfigFactory;
+import org.jboss.soa.si.InvocationAdapter;
import org.w3c.dom.Element;
import javax.transaction.*;
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -23,6 +23,7 @@
import org.jboss.soa.bpel.runtime.engine.PartnerChannel;
import org.jboss.soa.bpel.runtime.integration.ServerConfigFactory;
import org.jboss.soa.bpel.runtime.ws.*;
+import org.jboss.soa.si.ws.WSDLReference;
import javax.wsdl.Definition;
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/UDDIRegistration.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -25,7 +25,7 @@
import javax.xml.namespace.QName;
-import org.jboss.soa.bpel.runtime.ws.WSDLReference;
+import org.jboss.soa.si.ws.WSDLReference;
/**
*
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/BaseWebServiceEndpoint.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,226 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.soa.bpel.runtime.engine.BPELEngine;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.wsdl.Definition;
-import javax.wsdl.Operation;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-import javax.xml.soap.*;
-import javax.xml.ws.Provider;
-
-/**
- * Base class for BPEL endpoints that are created through javassist.
- * Represents a JAX-WS {@link javax.xml.ws.Provider} implementation.
- *
- * @see org.jboss.soa.bpel.runtime.ws.WebServiceProviderFactory
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class BaseWebServiceEndpoint implements Provider<SOAPMessage>
-{
- protected final Log log = LogFactory.getLog(getClass());
-
- private SOAPMessageAdapter soapAdapter;
- private QName serviceQName;
- private Definition wsdlDefinition;
-
- private boolean isInitialized;
-
- private void init()
- {
- if(!isInitialized)
- {
- try
- {
- WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
- this.wsdlDefinition = wsdlReader.readWSDL(getWsdlLocation());
- this.serviceQName = QName.valueOf(getServiceName());
- this.soapAdapter = new SOAPMessageAdapter(wsdlDefinition, serviceQName,
getPortName());
- }
- catch (WSDLException e)
- {
- throw new RuntimeException("Failed to parse WSDL", e);
- }
- isInitialized = true;
- }
- }
-
- public SOAPMessage invoke(SOAPMessage soapMessage)
- {
- log.debug("Invoking endpoint "+getEndpointId());
- init();
-
- try
- {
- SOAPPart soapPart = soapMessage.getSOAPPart();
- SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
- Element messageElement = getMessagePayload(soapEnvelope);
-
- if(log.isDebugEnabled())
- log.debug( "ODE inbound message: \n" +DOMWriter.printNode(soapEnvelope,
true) );
-
- // Create invocation context
- final String operationName = resolveOperationName(messageElement);
-
- WSInvocationAdapter invocationContext = new WSInvocationAdapter(
- operationName,
- serviceQName,
- getPortName(),
- soapAdapter
- );
- invocationContext.setSOAPMessage(soapMessage);
-
- // Invoke ODE
- getEngine().invoke(invocationContext);
-
- // Handle response
- SOAPMessage responseMessage = null;
-
- if (isResponseExpected(messageElement)) {
- responseMessage = invocationContext.getInvocationResult();
-
- if(log.isDebugEnabled())
- log.debug( "ODE outbound message: \n" +
- DOMWriter.printNode(responseMessage.getSOAPPart().getEnvelope(), true)
- );
- } else if (log.isDebugEnabled()) {
- log.debug( "ODE no outbound message");
- }
-
- if (responseMessage == null) {
- log.debug("No response, probably due to oneway request");
-
- // Need to create an empty response to avoid npe in jbossws (RIFTSAW-154)
- responseMessage = MessageFactory.newInstance().createMessage();
- }
-
- return responseMessage;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to invoke BPEL process:
"+e.getMessage(), e);
- }
- }
-
- public String resolveOperationName(Element payload)
- {
- if(soapAdapter.isRPC())
- {
- return payload.getLocalName();
- }
- else
- {
- QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
- Operation op = new WSDLParser(wsdlDefinition).getDocLitOperation(
- this.serviceQName, getPortName(), elementName
- );
-
- return op.getName();
- }
- }
-
- public boolean isResponseExpected(Element payload)
- {
- Operation op=null;
-
- if(soapAdapter.isRPC())
- {
- QName elementName = new QName(payload.getNamespaceURI(),
payload.getLocalName());
- op = new WSDLParser(wsdlDefinition).getRPCOperation(
- this.serviceQName, getPortName(), elementName
- );
- }
- else
- {
- QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
- op = new WSDLParser(wsdlDefinition).getDocLitOperation(
- this.serviceQName, getPortName(), elementName
- );
- }
-
- if (op == null) {
- throw new RuntimeException("Failed to locate operation definition for:
"+payload);
- }
-
- return op.getOutput() != null;
- }
-
- public static Element getMessagePayload(SOAPEnvelope soapEnvelope)
- throws SOAPException
- {
- SOAPBody body = soapEnvelope.getBody();
- Element messageElement = null; // first child of type Element
- NodeList children = body.getChildNodes();
- for(int i=0; i<children.getLength(); i++)
- {
- Node tmp = children.item(i);
- if(Node.ELEMENT_NODE == tmp.getNodeType())
- {
- messageElement = (Element)tmp;
- break;
- }
- }
- return messageElement;
- }
-
- public String getEndpointId() {
- return(null);
- }
-
- public String getServiceName() {
- return(null);
- }
-
- public String getWsdlLocation() {
- return(null);
- }
-
- public String getPortName() {
- return(null);
- }
-
- private BPELEngine getEngine()
- {
- try
- {
- InitialContext ctx = new InitialContext();
- return (BPELEngine)ctx.lookup("bpel/Engine");
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Failed to initialize BPEL engine");
- }
- }
-}
Deleted: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DOMWriter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DOMWriter.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DOMWriter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,656 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-/*
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (
http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Tomcat", and "Apache
Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache(a)apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <
http://www.apache.org/>.
- */
-
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Traverse a DOM tree in order to print a document that is parsed.
- *
- * @author Andy Clark, IBM
- * @author Thomas.Diesler(a)jboss.org
- */
-@SuppressWarnings("unchecked")
-public class DOMWriter
-{
- // Print writer
- private PrintWriter out;
- // True, if canonical output
- private boolean canonical;
- // True, if pretty printing should be used
- private boolean prettyprint;
- // True, if the XML declaration should be written
- private boolean writeXMLDeclaration;
- // True, if whitespace should be ignored
- private boolean ignoreWhitespace;
- // Explicit character set encoding
- private String charsetName;
- // indent for the pretty printer
- private int prettyIndent;
- // True, if the XML declaration has been written
- private boolean wroteXMLDeclaration;
- // The node that started the write
- private Node rootNode;
- // True if we want namespace completion
- private boolean completeNamespaces = true;
- // The current default namespace
- private String currentDefaultNamespace;
-
- public DOMWriter(Writer w)
- {
- this.out = new PrintWriter(w);
- }
-
- public DOMWriter(Writer w, String charsetName)
- {
- this.out = new PrintWriter(w);
- this.charsetName = charsetName;
- this.writeXMLDeclaration = true;
- }
-
- public DOMWriter(OutputStream stream)
- {
- try
- {
- this.out = new PrintWriter(new OutputStreamWriter(stream, "UTF-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- // ignore, UTF-8 should be available
- }
- }
-
- public DOMWriter(OutputStream stream, String charsetName)
- {
- try
- {
- this.out = new PrintWriter(new OutputStreamWriter(stream, charsetName));
- this.charsetName = charsetName;
- this.writeXMLDeclaration = true;
- }
- catch (UnsupportedEncodingException e)
- {
- throw new IllegalArgumentException("Unsupported encoding: " +
charsetName);
- }
- }
-
- /**
- * Print a node with explicit prettyprinting.
- * The defaults for all other DOMWriter properties apply.
- *
- */
- public static String printNode(Node node, boolean prettyprint)
- {
- StringWriter strw = new StringWriter();
- new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
- return strw.toString();
- }
-
- public boolean isCanonical()
- {
- return canonical;
- }
-
- /**
- * Set wheter entities should appear in their canonical form.
- * The default is false.
- */
- public DOMWriter setCanonical(boolean canonical)
- {
- this.canonical = canonical;
- return this;
- }
-
- public boolean isIgnoreWhitespace()
- {
- return ignoreWhitespace;
- }
-
- /**
- * Set whether whitespace should be ignored.
- * The default is false.
- */
- public DOMWriter setIgnoreWhitespace(boolean ignoreWhitespace)
- {
- this.ignoreWhitespace = ignoreWhitespace;
- return this;
- }
-
- /**
- * Set wheter subelements should have their namespaces completed.
- * Setting this to false may lead to invalid XML fragments.
- * The default is true.
- */
- public DOMWriter setCompleteNamespaces(boolean complete)
- {
- this.completeNamespaces = complete;
- return this;
- }
-
- public boolean isPrettyprint()
- {
- return prettyprint;
- }
-
- /**
- * Set wheter element should be indented.
- * The default is false.
- */
- public DOMWriter setPrettyprint(boolean prettyprint)
- {
- this.prettyprint = prettyprint;
- return this;
- }
-
- public boolean isWriteXMLDeclaration()
- {
- return writeXMLDeclaration;
- }
-
- /**
- * Set wheter the XML declaration should be written.
- * The default is false.
- */
- public DOMWriter setWriteXMLDeclaration(boolean flag)
- {
- this.writeXMLDeclaration = flag;
- return this;
- }
-
- public void print(Node node)
- {
- if (prettyprint && ignoreWhitespace)
- throw new IllegalStateException("Cannot pretty print and ignore
whitespace");
-
- rootNode = node;
- printInternal(node, false);
- }
-
- private void printInternal(Node node, boolean indentEndMarker)
- {
- // is there anything to do?
- if (node == null)
- {
- return;
- }
-
- // JBAS-2117 - Don't skip the DOCUMENT_NODE
- // if (node instanceof Document) node = ((Document)node).getDocumentElement();
-
- if (wroteXMLDeclaration == false && writeXMLDeclaration == true &&
canonical == false)
- {
- out.print("<?xml version='1.0'");
- if (charsetName != null)
- out.print(" encoding='" + charsetName + "'");
-
- out.print("?>");
- if (prettyprint)
- out.println();
-
- wroteXMLDeclaration = true;
- }
-
- int type = node.getNodeType();
- boolean hasChildNodes = node.getChildNodes().getLength() > 0;
-
- String nodeName = node.getNodeName();
- switch (type)
- {
- // print document
- case Node.DOCUMENT_NODE:
- {
- NodeList children = node.getChildNodes();
- int len = children.getLength();
- for (int iChild = 0; iChild < len; iChild++)
- {
- printInternal(children.item(iChild), false);
- }
- out.flush();
- break;
- }
-
- // print element with attributes
- case Node.ELEMENT_NODE:
- {
- Element element = (Element)node;
- if (prettyprint)
- {
- for (int i = 0; i < prettyIndent; i++)
- {
- out.print(' ');
- }
- prettyIndent++;
- }
-
- out.print('<');
- out.print(nodeName);
-
- Map nsMap = new HashMap();
- String elPrefix = node.getPrefix();
- String elNamespaceURI = node.getNamespaceURI();
- if (elPrefix != null)
- {
- String nsURI = getNamespaceURI(elPrefix, element, rootNode);
- nsMap.put(elPrefix, nsURI);
- }
-
- Attr attrs[] = sortAttributes(node.getAttributes());
- for (int i = 0; i < attrs.length; i++)
- {
- Attr attr = attrs[i];
- String atPrefix = attr.getPrefix();
- String atName = attr.getNodeName();
- String atValue = normalize(attr.getNodeValue(), canonical);
-
- if (atName.equals("xmlns"))
- currentDefaultNamespace = atValue;
-
- if (atPrefix != null && !atPrefix.equals("xmlns")
&& !atPrefix.equals("xml"))
- {
- String nsURI = getNamespaceURI(atPrefix, element, rootNode);
- nsMap.put(atPrefix, nsURI);
- // xsi:type='ns1:SubType', xsi:type='xsd:string'
- if (atName.equals(atPrefix + ":type") &&
atValue.indexOf(":") > 0)
- {
- // xsi defined on the envelope
- if (nsURI == null)
- nsURI = getNamespaceURI(atPrefix, element, null);
-
- if
("http://www.w3.org/2001/XMLSchema-instance".equals(nsURI))
- {
- String typePrefix = atValue.substring(0,
atValue.indexOf(":"));
- String typeURI = getNamespaceURI(typePrefix, element, rootNode);
- nsMap.put(typePrefix, typeURI);
- }
- }
- }
-
- out.print(" " + atName + "='" + atValue +
"'");
- }
-
- // Add namespace declaration for prefixes
- // that are defined further up the tree
- if (completeNamespaces)
- {
- Iterator itPrefix = nsMap.keySet().iterator();
- while (itPrefix.hasNext())
- {
- String prefix = (String)itPrefix.next();
- String nsURI = (String)nsMap.get(prefix);
- if (nsURI == null)
- {
- nsURI = getNamespaceURI(prefix, element, null);
- out.print(" xmlns:" + prefix + "='" + nsURI
+ "'");
- }
- }
- }
-
- // The SAX ContentHandler will by default not add the namespace declaration
- // <Hello xmlns='http://somens'>World</Hello>
- if (elPrefix == null && elNamespaceURI != null)
- {
- String defaultNamespace = element.getAttribute("xmlns");
- if (defaultNamespace.length() == 0 &&
!elNamespaceURI.equals(currentDefaultNamespace))
- {
- out.print(" xmlns='" + elNamespaceURI +
"'");
- currentDefaultNamespace = elNamespaceURI;
- }
- }
-
- if (hasChildNodes)
- {
- out.print('>');
- }
-
- // Find out if the end marker is indented
- indentEndMarker = isEndMarkerIndented(node);
-
- if (indentEndMarker)
- {
- out.print('\n');
- }
-
- NodeList childNodes = node.getChildNodes();
- int len = childNodes.getLength();
- for (int i = 0; i < len; i++)
- {
- Node childNode = childNodes.item(i);
- printInternal(childNode, false);
- }
- break;
- }
-
- // handle entity reference nodes
- case Node.ENTITY_REFERENCE_NODE:
- {
- if (canonical)
- {
- NodeList children = node.getChildNodes();
- if (children != null)
- {
- int len = children.getLength();
- for (int i = 0; i < len; i++)
- {
- printInternal(children.item(i), false);
- }
- }
- }
- else
- {
- out.print('&');
- out.print(nodeName);
- out.print(';');
- }
- break;
- }
-
- // print cdata sections
- case Node.CDATA_SECTION_NODE:
- {
- if (canonical)
- {
- out.print(normalize(node.getNodeValue(), canonical));
- }
- else
- {
- out.print("<![CDATA[");
- out.print(node.getNodeValue());
- out.print("]]>");
- }
- break;
- }
-
- // print text
- case Node.TEXT_NODE:
- {
- String text = normalize(node.getNodeValue(), canonical);
- if (text.trim().length() > 0)
- {
- out.print(text);
- }
- else if (prettyprint == false && ignoreWhitespace == false)
- {
- out.print(text);
- }
- break;
- }
-
- // print processing instruction
- case Node.PROCESSING_INSTRUCTION_NODE:
- {
- out.print("<?");
- out.print(nodeName);
- String data = node.getNodeValue();
- if (data != null && data.length() > 0)
- {
- out.print(' ');
- out.print(data);
- }
- out.print("?>");
- break;
- }
-
- // print comment
- case Node.COMMENT_NODE:
- {
- for (int i = 0; i < prettyIndent; i++)
- {
- out.print(' ');
- }
-
- out.print("<!--");
- String data = node.getNodeValue();
- if (data != null)
- {
- out.print(data);
- }
- out.print("-->");
-
- if (prettyprint)
- {
- out.print('\n');
- }
-
- break;
- }
- }
-
- if (type == Node.ELEMENT_NODE)
- {
- if (prettyprint)
- prettyIndent--;
-
- if (hasChildNodes == false)
- {
- out.print("/>");
- }
- else
- {
- if (indentEndMarker)
- {
- for (int i = 0; i < prettyIndent; i++)
- {
- out.print(' ');
- }
- }
-
- out.print("</");
- out.print(nodeName);
- out.print('>');
- }
-
- if (prettyIndent > 0)
- {
- out.print('\n');
- }
- }
- out.flush();
- }
-
- private String getNamespaceURI(String prefix, Element element, Node stopNode)
- {
- Node parent = element.getParentNode();
- String nsURI = element.getAttribute("xmlns:" + prefix);
- if (nsURI.length() == 0 && element != stopNode && parent instanceof
Element)
- return getNamespaceURI(prefix, (Element)parent, stopNode);
-
- return (nsURI.length() > 0 ? nsURI : null);
- }
-
- private boolean isEndMarkerIndented(Node node)
- {
- if (prettyprint)
- {
- NodeList childNodes = node.getChildNodes();
- int len = childNodes.getLength();
- for (int i = 0; i < len; i++)
- {
- Node children = childNodes.item(i);
- if (children.getNodeType() == Node.ELEMENT_NODE)
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /** Returns a sorted list of attributes. */
- private Attr[] sortAttributes(NamedNodeMap attrs)
- {
-
- int len = (attrs != null) ? attrs.getLength() : 0;
- Attr array[] = new Attr[len];
- for (int i = 0; i < len; i++)
- {
- array[i] = (Attr)attrs.item(i);
- }
- for (int i = 0; i < len - 1; i++)
- {
- String name = array[i].getNodeName();
- int index = i;
- for (int j = i + 1; j < len; j++)
- {
- String curName = array[j].getNodeName();
- if (curName.compareTo(name) < 0)
- {
- name = curName;
- index = j;
- }
- }
- if (index != i)
- {
- Attr temp = array[i];
- array[i] = array[index];
- array[index] = temp;
- }
- }
- return (array);
- }
-
- /** Normalizes the given string. */
- public static String normalize(String s, boolean canonical)
- {
- int len = (s != null) ? s.length() : 0;
- StringBuilder str = new StringBuilder();
-
- for (int i = 0; i < len; i++)
- {
- char ch = s.charAt(i);
- switch (ch)
- {
- case '<':
- {
- str.append("<");
- break;
- }
- case '>':
- {
- str.append(">");
- break;
- }
- case '&':
- {
- str.append("&");
- break;
- }
- case '"':
- {
- str.append(""");
- break;
- }
- case '\'':
- {
- str.append("'");
- break;
- }
- case '\r':
- case '\n':
- {
- if (canonical)
- {
- str.append("&#");
- str.append(Integer.toString(ch));
- str.append(';');
- break;
- }
- // else, default append char
- }
- default:
- {
- str.append(ch);
- }
- }
- }
- return (str.toString());
- }
-}
\ No newline at end of file
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -43,6 +43,10 @@
import org.jboss.soa.bpel.runtime.integration.KernelLocator;
import org.jboss.soa.bpel.runtime.integration.ServerConfig;
import org.jboss.soa.bpel.runtime.integration.ServerConfigFactory;
+import org.jboss.soa.si.ws.BaseWebServiceEndpoint;
+import org.jboss.soa.si.ws.WSDLParser;
+import org.jboss.soa.si.ws.WSDLReference;
+import org.jboss.soa.si.ws.WebServiceProviderFactory;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -59,7 +63,7 @@
* This instance is stateful and retains references to both endpoints and clients.
* As such it should only exists once.
*
- * @see org.jboss.soa.bpel.runtime.ws.BaseWebServiceEndpoint
+ * @see org.jboss.soa.si.ws.BaseWebServiceEndpoint
* @see org.jboss.soa.bpel.runtime.ws.WebServiceClient
* @see org.jboss.soa.bpel.runtime.engine.ode.JAXWSBindingContext
*
Deleted: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/JavaUtils.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,105 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-import java.io.ByteArrayOutputStream;
-import java.lang.reflect.Method;
-
-import javax.xml.soap.SOAPMessage;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- * @author Jeff Yu <cyu(a)redhat.com>
- */
-public class JavaUtils
-{
- protected static final Log log = LogFactory.getLog(JavaUtils.class);
-
- public static boolean isJBossRepositoryClassLoader(ClassLoader loader)
- {
- Class clazz = loader.getClass();
- while (!clazz.getName().startsWith("java"))
- {
- if
("org.jboss.mx.loading.RepositoryClassLoader".equals(clazz.getName()))
- return true;
- clazz = clazz.getSuperclass();
- }
-
- return false;
- }
-
- /**
- * Clears black lists on a JBoss RepositoryClassLoader. This is somewhat of a hack,
and
- * could be replaced with an integration module. This is needed when the following
order of
- * events occur.
- *
- * <ol>
- * <li>loadClass() returns not found</li>
- * <li>Some call to defineClass()</li>
- * <ol>
- *
- * The CNFE triggers a black list addition, which cause the class never again to be
found.
- *
- * @param loader the loader to clear black lists for
- */
- public static void clearBlacklists(ClassLoader loader)
- {
- if (isJBossRepositoryClassLoader(loader))
- {
- for(Method m : loader.getClass().getMethods())
- {
- if("clearBlackLists".equalsIgnoreCase(m.getName()))
- {
- try
- {
- m.invoke(loader);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- }
- }
-
- /**
- * Convert the SoapMessage object into String.
- * @param soapMessage
- * @return
- */
- public static String getSoapMessageASString(SOAPMessage soapMessage) {
- try {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- soapMessage.writeTo(outputStream);
- byte[] byteArray = outputStream.toByteArray();
- String soapMsg = new String( byteArray, "UTF-8");
- return soapMsg;
- } catch (Exception e) {
- log.error("Error in converting SOAPMessage into String");
- }
- return null;
- }
-}
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ODEWebServiceFactory.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ODEWebServiceFactory.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/ODEWebServiceFactory.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. 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.jboss.soa.bpel.runtime.ws;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.namespace.QName;
+
+import org.jboss.soa.bpel.runtime.engine.BPELEngine;
+import org.jboss.soa.si.ServiceInvoker;
+import org.jboss.soa.si.ws.SOAPMessageAdapter;
+import org.jboss.soa.si.ws.WebServiceFactory;
+
+public class ODEWebServiceFactory implements WebServiceFactory {
+
+ public ServiceInvoker getServiceInvoker() {
+ return(getEngine());
+ }
+
+ public WSInvocationAdapter getInvocationAdapter(String operationName,
+ QName serviceName, String portName, SOAPMessageAdapter soapAdapter) {
+ return(new WSInvocationAdapter(operationName,
+ serviceName, portName, soapAdapter));
+ }
+
+ private BPELEngine getEngine() {
+ try {
+ InitialContext ctx = new InitialContext();
+ return (BPELEngine)ctx.lookup("bpel/Engine");
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to initialize BPEL engine");
+ }
+ }
+}
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,644 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.iapi.Message;
-import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.stl.CollectionsX;
-import org.apache.ode.utils.wsdl.WsdlUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.wsdl.*;
-import javax.wsdl.extensions.ElementExtensible;
-import javax.wsdl.extensions.soap.SOAPBinding;
-import javax.wsdl.extensions.soap.SOAPHeader;
-import javax.xml.namespace.QName;
-import javax.xml.soap.*;
-
-import java.util.*;
-
-/**
- * Adopts {@link javax.xml.soap.SOAPMessage}'s to ODE's internal
- * {@link org.apache.ode.bpel.iapi.Message} representation and vice versa.
- *
- * @see org.jboss.soa.bpel.runtime.ws.WebServiceClient
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class SOAPMessageAdapter
-{
- protected final Log log = LogFactory.getLog(getClass());
-
- private Definition wsdl;
- private QName serviceName;
-
- private String portName;
- private Service serviceDef;
- private Binding binding;
-
- private Port port;
- private boolean isRPC;
-
- private SOAPBinding soapBinding;
-
- private SOAPFactory soapFactory;
-
- public SOAPMessageAdapter(Definition wsdl, QName serviceName, String portName)
- {
- this.wsdl = wsdl;
- this.serviceName = serviceName;
- this.portName = portName;
-
- serviceDef = wsdl.getService(serviceName);
- if (serviceDef == null)
- throw new RuntimeException("Service not found "+serviceName);
-
- port = serviceDef.getPort(portName);
- if (port == null)
- throw new RuntimeException("Port '"+portName+"' not found on
service: "+serviceName);
-
- binding = port.getBinding();
- if (binding == null)
- throw new RuntimeException("No binding for port "+portName);
-
- if (!WsdlUtils.useSOAPBinding(port)) {
- throw new RuntimeException("No SOAP binding for port"+portName);
- }
- soapBinding = (SOAPBinding) WsdlUtils.getBindingExtension(port);
-
-
- String style = soapBinding.getStyle();
- isRPC = style != null && style.equals("rpc");
-
- try
- {
- this.soapFactory = SOAPFactory.newInstance();
- }
- catch (SOAPException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * This method creates the SOAP request and returns the SOAPAction field.
- *
- * @param soapMessage
- * @param odeRequestMessage
- * @param wsdlOperation
- * @return The SOAP action
- */
- public String createSoapRequest(SOAPMessage soapMessage, Message odeRequestMessage,
Operation wsdlOperation)
- {
- String ret=null;
-
- BindingOperation bop = binding.getBindingOperation(wsdlOperation.getName(), null,
null);
- if (bop == null)
- throw new RuntimeException("Operation "+wsdlOperation.getName()+"not
found on "+serviceName+"/"+portName);
-
- BindingInput bi = bop.getBindingInput();
- if (bi == null)
- throw new RuntimeException("Binding input not found on
"+serviceName+"/"+portName);
-
- // Headers
- createSoapHeaders(
- soapMessage,
- getSOAPHeaders(bi),
- wsdlOperation.getInput().getMessage(),
- odeRequestMessage.getHeaderParts(),
- odeRequestMessage.getMessage()
- );
-
-
- // SOAP Body
- javax.wsdl.extensions.soap.SOAPBody wsdlSoapBody = getSOAPBody(bi);
-
- createSoapBody(
- soapMessage,
- wsdlSoapBody,
- wsdlOperation.getInput().getMessage(),
- odeRequestMessage.getMessage(),
- wsdlOperation.getName()
- );
-
- // Discover SOAPAction
- for (Object extension : bop.getExtensibilityElements()) {
- if (extension instanceof javax.wsdl.extensions.soap.SOAPOperation) {
- javax.wsdl.extensions.soap.SOAPOperation soapop=
- (javax.wsdl.extensions.soap.SOAPOperation)extension;
-
- if (soapop.getSoapActionURI() != null) {
- ret = soapop.getSoapActionURI();
- break;
- }
- }
- }
-
- return(ret);
- }
-
- public boolean isRPC()
- {
- return isRPC;
- }
-
- public void createSoapResponse(SOAPMessage soapMessage, Message odeResponseMessage,
Operation wsdlOperation)
- {
-
- BindingOperation bop =
binding.getBindingOperation(wsdlOperation.getName(),null,null);
- if (bop == null)
- throw new RuntimeException("Operation "+wsdlOperation.getName()+"not
found on "+serviceName+"/"+portName);
-
- BindingOutput bo = bop.getBindingOutput();
- if (bo == null)
- throw new RuntimeException("Binding output not found on
"+serviceName+"/"+portName);
-
- // Headers
- if (odeResponseMessage.getHeaderParts().size() > 0 || getSOAPHeaders(bo).size()
> 0)
- createSoapHeaders(
- soapMessage,
- getSOAPHeaders(bo),
- wsdlOperation.getOutput().getMessage(),
- odeResponseMessage.getHeaderParts(),
- odeResponseMessage.getMessage()
- );
-
-
- // SOAP Body
- javax.wsdl.extensions.soap.SOAPBody wsdlSOAPBody = getSOAPBody(bo);
- createSoapBody(
- soapMessage,
- wsdlSOAPBody,
- wsdlOperation.getOutput().getMessage(),
- odeResponseMessage.getMessage(),
- wsdlOperation.getName() + "Response"
- );
-
- }
-
- private void createSoapBody(SOAPMessage soapMessage,
- javax.wsdl.extensions.soap.SOAPBody wsdlSoapBody,
javax.wsdl.Message wsdlMessageDef,
- Element message, String operationName)
- {
- try
- {
- SOAPBody soapBody = soapMessage.getSOAPBody();
-
- SOAPElement partHolder = null;
- if(isRPC)
- {
- partHolder = soapFactory.createElement(new QName(wsdlSoapBody.getNamespaceURI(),
operationName, "odens"));
- }
- else
- {
- partHolder = soapBody;
- }
-
- List<Part> parts = wsdlMessageDef.getOrderedParts(wsdlSoapBody.getParts());
- for(Part part : parts)
- {
- Element srcPartEl = DOMUtils.findChildByName(message, new QName(null,
part.getName()));
- if (srcPartEl == null)
- throw new RuntimeException("Part is missing: " +part.getName());
-
- SOAPElement partElement = soapFactory.createElement(srcPartEl);
- if (isRPC)
- {
- partHolder.addChildElement(partElement);
- }
- else
- {
- for (Iterator<SOAPElement> i = partElement.getChildElements();
i.hasNext();) partHolder.addChildElement(i.next());
- }
- }
-
- // late bind
- if(isRPC)
- soapBody.addChildElement(partHolder);
- }
- catch (SOAPException e)
- {
- throw new RuntimeException("Failed to create soap body",e);
- }
- }
-
- private void createSoapHeaders(SOAPMessage soapMessage, List<SOAPHeader>
headers,
- javax.wsdl.Message wsdlMessageDef,
- Map<String, Node> headerParts, Element message)
- {
- try {
- javax.xml.soap.SOAPHeader soapHeader = soapMessage.getSOAPHeader();
- if (soapHeader==null) soapHeader =
soapMessage.getSOAPPart().getEnvelope().addHeader();
- for (Node headerNode : headerParts.values()) {
- //like we may have password header with null value.
- if(headerNode == null){
- continue;
- }
- if (Node.ELEMENT_NODE == headerNode.getNodeType()) {
- if (getFirstChildWithName(new QName(headerNode.getNamespaceURI(),
headerNode.getLocalName()),soapHeader) == null) {
- SOAPElement partElement = soapFactory.createElement((Element) headerNode);
- soapHeader.addChildElement(partElement);
- }
- } else {
- throw new RuntimeException("SOAP header must be a node_element " +
headerNode);
- }
- }
-
- //Add soap header according to binding.
- for (SOAPHeader header : headers) {
- Element headerEl = DOMUtils.findChildByName(message, new QName(null,
header.getPart()));
- if (headerEl != null) {
-
- // RIFTSAW-305 - don't think the part name should be added to the SOAP header
- //SOAPElement soapHeaderEl = soapFactory.createElement(new
QName(header.getMessage().getNamespaceURI(), header.getPart(),"odens"));
- NodeList list = headerEl.getChildNodes();
- for(int i=0; i< list.getLength(); i++) {
- SOAPElement partElement = soapFactory.createElement((Element)list.item(i));
- soapHeader.addChildElement(partElement);
- }
- //soapHeader.addChildElement(soapHeaderEl);
- }
- }
- } catch (SOAPException e) {
- throw new RuntimeException("Failed to create soap header",e);
- }
- }
-
- public void parseSoapResponse(org.apache.ode.bpel.iapi.Message odeMessage,
- SOAPMessage soapMessage, javax.wsdl.Operation
odeOperation) {
- BindingOperation bop = binding.getBindingOperation(odeOperation.getName(), null,
null);
- if (bop == null)
- throw new RuntimeException("Operation "+odeOperation.getName()+"not
found on "+serviceName+"/"+portName);
-
- BindingOutput bo = bop.getBindingOutput();
- if (bo == null)
- throw new RuntimeException("Binding output not found on
"+serviceName+"/"+portName);
-
- extractSoapBodyParts(odeMessage, soapMessage, getSOAPBody(bo),
odeOperation.getOutput().getMessage(), odeOperation.getName() + "Response");
- extractSoapHeaderParts(odeMessage, soapMessage, getSOAPHeaders(bo),
odeOperation.getOutput().getMessage());
- }
-
- public void parseSoapRequest(
- org.apache.ode.bpel.iapi.Message odeMessage,
- SOAPMessage soapMessage,
- Operation op)
- {
-
- BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);
-
- if (bop == null)
- throw new RuntimeException("Binding operation not found
("+serviceName+"/"+portName);
-
- BindingInput bi = bop.getBindingInput();
- if (bi == null)
- throw new RuntimeException("Binding input not
found"+serviceName+"/"+portName);
-
- extractSoapBodyParts(odeMessage, soapMessage, getSOAPBody(bi),
op.getInput().getMessage(), op.getName());
- extractSoapHeaderParts(odeMessage, soapMessage, getSOAPHeaders(bi),
op.getInput().getMessage());
- }
-
- public void createSoapFault(SOAPMessage soapMessage, Element message, QName faultName,
Operation op)
- {
- try
- {
- Element detail = buildSoapDetail(message, faultName, op);
- SOAPFault fault = soapMessage.getSOAPBody().addFault();
- fault.setFaultCode(faultName);
- if(detail!=null)
- fault.addDetail().addChildElement(soapFactory.createElement(detail));
- }
- catch (SOAPException e)
- {
- throw new RuntimeException("Failed to create fault", e);
- }
- }
-
- private Element buildSoapDetail(Element message, QName faultName, Operation op)
- {
- if (faultName.getNamespaceURI() == null)
- return toFaultDetail(faultName, message);
- if (op == null) {
- return toFaultDetail(faultName, message);
- }
- Fault f = op.getFault(faultName.getLocalPart());
- if (f == null)
- return toFaultDetail(faultName, message);
-
- // For faults, there will be exactly one part.
- Part p = (Part)f.getMessage().getParts().values().iterator().next();
- if (p == null)
- return toFaultDetail(faultName, message);
- Element partEl= DOMUtils.findChildByName(message,new QName(null,p.getName()));
- if (partEl == null)
- return toFaultDetail(faultName, message);
- Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
- if (detail == null)
- return toFaultDetail(faultName, message);
-
- return detail;
- }
-
- private Element toFaultDetail(QName fault, Element message) {
- if (message == null) return null;
- Element firstPart = DOMUtils.getFirstChildElement(message);
- if (firstPart == null) return null;
- Element detail = DOMUtils.getFirstChildElement(firstPart);
- if (detail == null) return firstPart;
- return detail;
- }
-
- private void extractSoapHeaderParts(Message odeMessage, SOAPMessage soapMessage,
List<SOAPHeader> headerDefs,javax.wsdl.Message wsdlMessageDef)
- {
- try {
- javax.xml.soap.SOAPHeader soapHeader = soapMessage.getSOAPHeader();
- // Checking that the definitions we have are at least there
- for (SOAPHeader headerDef : headerDefs)
- handleSoapHeaderPartDef(odeMessage, soapHeader, headerDef, wsdlMessageDef);
-
- // Extracting whatever header elements we find in the message, binding and
abstract parts
- // aren't reliable enough given what people do out there.
- if (soapHeader != null) {
- Iterator headersIter = soapHeader.getChildElements();
- while (headersIter.hasNext()) {
- Object obj=headersIter.next();
-
- // Should be SOAPHeaderElement, but CXF also returns javax.xml.soap.Text
- // objects aswell
- if (obj instanceof javax.xml.soap.SOAPHeaderElement) {
- javax.xml.soap.SOAPHeaderElement headerElem =
(javax.xml.soap.SOAPHeaderElement) obj;
- String partName = findHeaderPartName(headerDefs,
headerElem.getElementQName());
- Document doc = DOMUtils.newDocument();
-
- // RIFTSAW-74 - slight modification to avoid jbossws exception when
reconstructing the
- // SOAP message.
-
- //Element destPart = doc.createElementNS(null, partName);
- //destPart.appendChild(doc.importNode(headerElem, true));
- //odeMessage.setHeaderPart(partName, destPart);
- odeMessage.setHeaderPart(partName, (Element)doc.importNode(headerElem, true));
- }
- }
- }
- }
- catch (SOAPException e)
- {
- throw new RuntimeException("Failed to extracts header parts",e);
- }
- }
-
- private String findHeaderPartName(List<SOAPHeader> headerDefs, QName elmtName) {
- for (SOAPHeader headerDef : headerDefs) {
- javax.wsdl.Message hdrMsg = wsdl.getMessage(headerDef.getMessage());
- for (Object o : hdrMsg.getParts().values()) {
- Part p = (Part) o;
- if (p.getElementName() != null &&
- p.getElementName().equals(elmtName)) return p.getName();
- }
- }
- return elmtName.getLocalPart();
- }
-
- private void handleSoapHeaderPartDef(Message odeMessage, javax.xml.soap.SOAPHeader
header, SOAPHeader headerdef,
- javax.wsdl.Message msgType) {
- // Is this header part of the "payload" messsage?
- boolean payloadMessageHeader = headerdef.getMessage() == null ||
headerdef.getMessage().equals(msgType.getQName());
- boolean requiredHeader = payloadMessageHeader ||
Boolean.TRUE.equals(headerdef.getRequired());
-
- if (header == null) {
- if (requiredHeader)
- throw new RuntimeException("Soap Header is missing a required field " +
headerdef.getElementType());
-
- return;
- }
-
- javax.wsdl.Message hdrMsg = wsdl.getMessage(headerdef.getMessage());
- if (hdrMsg == null)
- return;
- Part p = hdrMsg.getPart(headerdef.getPart());
- if (p == null || p.getElementName() == null)
- return;
-
- SOAPElement headerEl = getFirstChildWithName(p.getElementName(), header);
- if (requiredHeader && headerEl == null)
- throw new RuntimeException("Soap Header is missing a required field "
+ headerdef.getElementType());
-
- if (headerEl == null) return;
-
- /* RIFTSAW-127 - this was duplicating the header part in the consolidated (merged)
message stored in the
- * BPEL process - but this code actually causes two levels of 'part' to be
defined - e.g.
- * <conversionId><conversationId><details ....
/></conversatioId></conversationId>
- Document doc = DOMUtils.newDocument();
- Element destPart = doc.createElementNS(null, p.getName());
- destPart.appendChild(doc.importNode(headerEl, true));
- odeMessage.setHeaderPart(p.getName(), destPart);
- */
- }
-
- private void extractSoapBodyParts(
- Message odeMessage,
- SOAPMessage soapMessage,
- javax.wsdl.extensions.soap.SOAPBody wsdlSOAPBody,
- javax.wsdl.Message wsdlMessageDef, String operationName)
- {
- try
- {
- SOAPBody soapBody = soapMessage.getSOAPBody();
- List<Part> parts = wsdlMessageDef.getOrderedParts(wsdlSOAPBody.getParts());
-
- if(isRPC)
- {
- // In RPC the body element is the operation name, wrapping parts. Order
doesn't really matter as far as
- // we're concerned. All we need to do is copy the soap:body children, since
doc-lit rpc looks the same
- // in ode and soap.
-
- QName rpcWrapQName = new QName(wsdlSOAPBody.getNamespaceURI(), operationName);
- SOAPElement partWrapper = getFirstChildWithName(rpcWrapQName, soapBody);
-
- if (partWrapper == null)
- throw new RuntimeException("Expected part wrapper
'"+rpcWrapQName+"'missing on
service:"+serviceName+"/"+portName);
-
- for(Part part : parts)
- {
- SOAPElement srcPart = getFirstChildWithName(new QName(null, part.getName()),
partWrapper);
- if (srcPart == null)
- throw new RuntimeException("Soap body does not contain required part
+"+part.getName());
-
- odeMessage.setPart(srcPart.getLocalName(), srcPart);
- }
- }
- else
- {
- // In doc-literal style, we expect the elements in the body to correspond (in
order)
- // to the parts defined in the binding.
- // All the parts should be element-typed, otherwise it is a mess.
- List<SOAPElement> childElements = new ArrayList<SOAPElement>();
- final Iterator children = soapBody.getChildElements() ;
- while(children.hasNext())
- {
- final Node node = (Node)children.next() ;
- if (node instanceof SOAPElement)
- childElements.add((SOAPElement)node);
- }
-
- Iterator<SOAPElement> srcParts = childElements.iterator();
- for(Part part : parts)
- {
- SOAPElement srcPart = srcParts.next();
- Document doc = DOMUtils.newDocument();
- Element destPart = doc.createElementNS(null, part.getName());
- destPart.appendChild(doc.importNode(srcPart, true));
- odeMessage.setPart(part.getName(), destPart);
- }
- }
- }
- catch (SOAPException e)
- {
- throw new RuntimeException("Failed to extract soap body parts", e);
- }
- }
-
- private static SOAPElement getFirstChildWithName(QName name, SOAPElement parent)
- {
- SOAPElement match = null;
- Iterator iterator = parent.getChildElements(name);
- while(iterator.hasNext())
- {
- match= (SOAPElement)iterator.next();
- }
- return match;
- }
-
- /*private static Element cloneElement(Element source)
- {
- // TODO:
https://jira.jboss.org/jira/browse/RIFTSAW-38
- // For now create a deep copy (performance hit)
- try
- {
- DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = builder.newDocument();
- return (Element)doc.importNode(source, true);
- }
- catch (ParserConfigurationException e)
- {
- throw new RuntimeException(e);
- }
- } */
-
- public static <T> T getFirstExtensibilityElement(ElementExtensible parent,
Class<T> cls) {
- Collection<T> ee = CollectionsX.filter(parent.getExtensibilityElements(),
cls);
-
- return ee.isEmpty() ? null : ee.iterator().next();
-
- }
-
- public static javax.wsdl.extensions.soap.SOAPBody getSOAPBody(ElementExtensible ee) {
- return getFirstExtensibilityElement(ee, javax.wsdl.extensions.soap.SOAPBody.class);
- }
-
- public static List<SOAPHeader> getSOAPHeaders(ElementExtensible eee) {
- return CollectionsX.filter(new ArrayList<SOAPHeader>(),
(Collection<Object>) eee.getExtensibilityElements(),
- SOAPHeader.class);
- }
-
- public static Fault parseSoapFault(
- Element odeMessage,
- SOAPMessage soapMessage,
- javax.wsdl.Operation operation)
- {
- Fault fdef = null;
- try
- {
- SOAPFault flt = soapMessage.getSOAPBody().getFault();
- Detail detail = flt.getDetail();
- fdef = inferFault(operation, flt);
- if(fdef!=null)
- {
- Part pdef = (Part)fdef.getMessage().getParts().values().iterator().next();
- Element partel =
odeMessage.getOwnerDocument().createElementNS(null,pdef.getName());
- odeMessage.appendChild(partel);
-
- Element childByName = DOMUtils.findChildByName(detail, pdef.getElementName());
- if (childByName != null)
- {
- partel.appendChild(odeMessage.getOwnerDocument().importNode(childByName,
true));
- }
- else
- {
- partel.appendChild(odeMessage.getOwnerDocument().importNode(detail,true));
- }
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to parse SOAP Fault",e);
- }
-
- return fdef;
- }
-
- public static Fault parseSoapFault(
- Element odeMessage,
- SOAPFault flt,
- javax.wsdl.Operation operation)
- {
- Fault fault=inferFault(operation, flt);
-
- if(fault!=null)
- {
- Detail detail = flt.getDetail();
- Part pdef = (Part)fault.getMessage().getParts().values().iterator().next();
- Element partel =
odeMessage.getOwnerDocument().createElementNS(null,pdef.getName());
- odeMessage.appendChild(partel);
-
- Element childByName = DOMUtils.findChildByName(detail, pdef.getElementName());
- if (childByName != null)
- {
- partel.appendChild(odeMessage.getOwnerDocument().importNode(childByName,
true));
- }
- else
- {
- partel.appendChild(odeMessage.getOwnerDocument().importNode(detail,true));
- }
- }
-
- return fault;
- }
-
- private static Fault inferFault(Operation operation, SOAPFault flt) {
- if (!flt.hasDetail())
- return null;
- // The detail is a dummy <detail> node containing the interesting fault
element
- Element element = DOMUtils.getFirstChildElement(flt.getDetail());
-
- if (element == null) {
- return(null);
- }
-
- QName elName=new QName(element.getNamespaceURI(), element.getLocalName());
- return WsdlUtils.inferFault(operation, elName);
- }
-}
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/TemplateWebServiceEndpoint.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-
-import javax.xml.soap.*;
-import javax.xml.ws.Provider;
-
-/**
- * CXF requires the JAX-WS implementation class to directly implement the
- * Provider<SOAPMessage>, rather than be derived from a superclass that
- * implements it. Therefore this 'template' web service endpoint class
- * has been created, which will be loaded by javassist and renamed to
- * be the specific endpoint implementation. This is necessary as
- * javassist does not provide a way to set a interface that uses generics.
- *
- * @see org.jboss.soa.bpel.runtime.ws.WebServiceProviderFactory
- *
- */
-public class TemplateWebServiceEndpoint extends BaseWebServiceEndpoint implements
Provider<SOAPMessage>
-{
- // See RIFTSAW-123 for description of issue related to CXF
-}
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLHelper.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLHelper.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLHelper.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -14,6 +14,8 @@
import org.apache.ode.bpel.iapi.ContextException;
import org.apache.ode.bpel.iapi.ProcessConf;
import org.jboss.soa.bpel.runtime.engine.ode.BPELEngineImpl;
+import org.jboss.soa.si.ws.WSDLParser;
+import org.jboss.soa.si.ws.WSDLReference;
public class WSDLHelper {
Deleted: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLParser.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLParser.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLParser.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,223 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-import javax.wsdl.*;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.xml.namespace.QName;
-import java.net.URL;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * WSDL helper class
- */
-public final class WSDLParser
-{
-
- private Definition wsdlDefinition;
- private int dfsDepth = 0;
-
- public WSDLParser(Definition wsdlDefinition)
- {
- this.wsdlDefinition = wsdlDefinition;
- }
-
- public void reset()
- {
- dfsDepth = 0;
- }
-
- public Operation getRPCOperation(QName service, String port, QName payloadName)
- {
- reset();
- Operation result = _getRPCOperation(this.wsdlDefinition, service, port,
payloadName);
- if (result == null)
- throw new IllegalArgumentException("Unable to find operation for element
"+payloadName);
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private Operation _getRPCOperation(Definition wsdl, QName serviceName, String portName,
QName payloadName)
- {
- if(++dfsDepth>50) // easier then retaining references
- throw new IllegalStateException("Recursive loop detected. DFS depth reached
limit");
-
- // namespace / java.util.List of imports
- Collection<List<Import>> imports = wsdl.getImports().values();
- for(List<Import> importNS : imports)
- {
- for(Import wsdlImport : importNS)
- {
- Operation result = _getRPCOperation(wsdlImport.getDefinition(), serviceName,
portName, payloadName);
- if(result!=null)
- return result;
- }
- }
-
- // resolve the port & operation
- Service service = wsdl.getService(serviceName);
- if (service == null)
- return null; // service might be defined elsewhere
-
- Port port = service.getPort(portName);
- if (port == null)
- throw new IllegalArgumentException("service "+serviceName+" contains
no such port "+portName);
-
- Binding binding = port.getBinding();
- PortType portType = binding.getPortType();
- List<Operation> operations = portType.getOperations();
- for(Operation op : operations)
- {
- if(op.getName().equals(payloadName.getLocalPart()))
- return op;
- }
-
- return null;
- }
-
- public Operation getDocLitOperation(QName service, String port, QName payloadName)
- {
- reset();
- Operation result = _getDocLitOperation(this.wsdlDefinition, service, port,
payloadName);
- if (result == null)
- throw new IllegalArgumentException("Unable to find operation for element
"+payloadName);
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private Operation _getDocLitOperation(Definition wsdl, QName serviceName, String
portName, QName payloadName)
- {
- if(++dfsDepth>50) // easier then retaining references
- throw new IllegalStateException("Recursive loop detected. DFS depth reached
limit");
-
- // namespace / java.util.List of imports
- Collection<List<Import>> imports = wsdl.getImports().values();
- for(List<Import> importNS : imports)
- {
- for(Import wsdlImport : importNS)
- {
- Operation result = _getDocLitOperation(wsdlImport.getDefinition(), serviceName,
portName, payloadName);
- if(result!=null)
- return result;
- }
- }
-
- // resolve the port & operation
- Service service = wsdl.getService(serviceName);
- if (service == null)
- return null; // service might be defined elsewhere
-
- Port port = service.getPort(portName);
- if (port == null)
- throw new IllegalArgumentException("service "+serviceName+" contains
no such port "+portName);
-
- Binding binding = port.getBinding();
- PortType portType = binding.getPortType();
- List<Operation> operations = portType.getOperations();
- for(Operation op : operations)
- {
- Message message = op.getInput().getMessage();
- Collection<Part> parts = message.getParts().values();
- for(Part part : parts)
- {
- if(part.getElementName().equals(payloadName))
- return op;
- }
- }
-
- return null;
- }
-
- public URL getServiceLocationURL(QName serviceQName, String portName)
- {
- reset();
- return _getServiceLocationURL(this.wsdlDefinition, serviceQName, portName);
- }
-
- public URL _getServiceLocationURL(Definition wsdl, QName serviceQName, String
portName)
- {
- URL match = null;
- dfsDepth++;
-
- if(dfsDepth>50) // easier then retaining references
- throw new IllegalStateException("Recursive loop detected. DFS depth reached
limit");
-
- // namespace / java.util.List of imports
- Map<String, List<Import>> imports = wsdl.getImports();
- for(String ns : imports.keySet())
- {
- List<Import> importNS = imports.get(ns);
- for(Import wsdlImport : importNS)
- {
- URL result = _getServiceLocationURL(wsdlImport.getDefinition(), serviceQName,
portName);
- if(result!=null)
- {
- match = result;
- break;
- }
- }
-
- if(match!=null) break;
- }
-
- if(match!=null) // DFS results
- return match;
-
- try
- {
- Service service = wsdl.getService(serviceQName);
- Port port = null;
- SOAPAddress soapAddress = null;
-
- // --
-
- if(service!=null)
- {
- port = service.getPort(portName);
- if(port!=null)
- {
- for(Object obj : port.getExtensibilityElements())
- {
- if(obj instanceof SOAPAddress)
- {
- soapAddress = (SOAPAddress)obj;
- }
- }
-
- }
- }
-
- // --
-
- if(soapAddress!=null)
- match = new URL(soapAddress.getLocationURI());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to parse " + wsdl, e);
- }
-
- return match;
- }
-}
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLReference.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLReference.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLReference.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-import javax.wsdl.Definition;
-import java.net.URI;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-/**
- * Used to pass along both parsed and raw WSDL references.
- *
- * @see org.jboss.soa.bpel.runtime.engine.ode.JAXWSBindingContext
- * @see org.jboss.soa.bpel.runtime.ws.EndpointManager
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- * @author Kurt.Stam <kurt.stam(a)jboss.com>
- *
- */
-public final class WSDLReference
-{
- private Definition definition;
- private URI wsdlURI;
-
- public WSDLReference(Definition definition, URI wsdlURI)
- {
- this.definition = definition;
- this.wsdlURI = wsdlURI;
- }
-
- public Definition getDefinition()
- {
- return definition;
- }
-
- public URL getWsdlURL()
- {
- try
- {
- return wsdlURI.toURL();
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,118 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-import org.apache.ode.bpel.iapi.Message;
-import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
-import org.jboss.soa.bpel.runtime.engine.InvocationAdapter;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-
-/**
- * @author Heiko Braun <hbraun(a)redhat.com>
- */
-public final class WSInvocationAdapter implements InvocationAdapter<SOAPMessage>
-{
- private final String operationName;
- private final QName serviceName;
- private final String portName;
-
- private SOAPMessage soapRequestMessage;
- private SOAPMessage soapResponseMessage;
-
- private final SOAPMessageAdapter soapAdapter;
-
- public WSInvocationAdapter(String operationName,
- QName serviceName, String portName, SOAPMessageAdapter soapAdapter)
- {
- this.operationName = operationName;
- this.serviceName = serviceName;
- this.portName = portName;
- this.soapAdapter = soapAdapter;
- }
-
- public String getOperationName()
- {
- return operationName;
- }
-
- public QName getServiceName()
- {
- return serviceName;
- }
-
- public String getPortName()
- {
- return portName;
- }
-
- public void parseRequest(MyRoleMessageExchange mex, Message request)
- {
- if(null==soapRequestMessage)
- throw new IllegalArgumentException("No request SOAPMessage set");
-
- soapAdapter.parseSoapRequest(request, soapRequestMessage, mex.getOperation());
- }
-
- public void createResponse(MyRoleMessageExchange mex)
- {
- try
- {
- // create SOAPEnvelope
- soapResponseMessage = MessageFactory.newInstance().createMessage();
- soapAdapter.createSoapResponse(soapResponseMessage, mex.getResponse(),
mex.getOperation());
- }
- catch (SOAPException e)
- {
- throw new RuntimeException("Failed to create SOAP response", e);
- }
- }
-
- public void createFault(MyRoleMessageExchange mex)
- {
- try
- {
- soapResponseMessage = MessageFactory.newInstance().createMessage();
- soapAdapter.createSoapFault(soapResponseMessage,
mex.getFaultResponse().getMessage(), mex.getFault(), mex.getOperation() );
- }
- catch (SOAPException e)
- {
- throw new RuntimeException("Failed to create SOAP fault", e);
- }
- }
-
- public SOAPMessage getInvocationResult()
- {
- if(null==soapResponseMessage)
- throw new IllegalArgumentException("No response SOAPMessage set");
-
- return soapResponseMessage;
- }
-
- public void setSOAPMessage(SOAPMessage soapMessage)
- {
- this.soapRequestMessage = soapMessage;
- }
-}
Copied:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java
(from rev 1038,
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java)
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSInvocationAdapter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.bpel.runtime.ws;
+
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.jboss.soa.si.InvocationAdapter;
+import org.jboss.soa.si.ws.SOAPMessageAdapter;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+/**
+ * @author Heiko Braun <hbraun(a)redhat.com>
+ */
+public final class WSInvocationAdapter implements InvocationAdapter<SOAPMessage>
+{
+ private final String operationName;
+ private final QName serviceName;
+ private final String portName;
+
+ private SOAPMessage soapRequestMessage;
+ private SOAPMessage soapResponseMessage;
+
+ private final SOAPMessageAdapter soapAdapter;
+
+ public WSInvocationAdapter(String operationName,
+ QName serviceName, String portName, SOAPMessageAdapter soapAdapter)
+ {
+ this.operationName = operationName;
+ this.serviceName = serviceName;
+ this.portName = portName;
+ this.soapAdapter = soapAdapter;
+ }
+
+ public String getOperationName()
+ {
+ return operationName;
+ }
+
+ public QName getServiceName()
+ {
+ return serviceName;
+ }
+
+ public String getPortName()
+ {
+ return portName;
+ }
+
+ public void parseRequest(MyRoleMessageExchange mex, Message request)
+ {
+ if(null==soapRequestMessage)
+ throw new IllegalArgumentException("No request SOAPMessage set");
+
+ soapAdapter.parseSoapRequest(request, soapRequestMessage, mex.getOperation());
+ }
+
+ public void createResponse(MyRoleMessageExchange mex)
+ {
+ try
+ {
+ // create SOAPEnvelope
+ soapResponseMessage = MessageFactory.newInstance().createMessage();
+ soapAdapter.createSoapResponse(soapResponseMessage, mex.getResponse(),
mex.getOperation());
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to create SOAP response", e);
+ }
+ }
+
+ public void createFault(MyRoleMessageExchange mex)
+ {
+ try
+ {
+ soapResponseMessage = MessageFactory.newInstance().createMessage();
+ soapAdapter.createSoapFault(soapResponseMessage,
mex.getFaultResponse().getMessage(), mex.getFault(), mex.getOperation() );
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to create SOAP fault", e);
+ }
+ }
+
+ public SOAPMessage getInvocationResult()
+ {
+ if(null==soapResponseMessage)
+ throw new IllegalArgumentException("No response SOAPMessage set");
+
+ return soapResponseMessage;
+ }
+
+ public void setSOAPMessage(SOAPMessage soapMessage)
+ {
+ this.soapRequestMessage = soapMessage;
+ }
+}
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceClient.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -53,6 +53,10 @@
import org.jboss.soa.bpel.runtime.engine.ode.UDDIClientFactory;
import org.jboss.soa.bpel.runtime.engine.ode.UDDIRegistration;
import org.jboss.soa.bpel.runtime.integration.ServerConfigFactory;
+import org.jboss.soa.si.ws.DOMWriter;
+import org.jboss.soa.si.ws.JavaUtils;
+import org.jboss.soa.si.ws.SOAPMessageAdapter;
+import org.jboss.soa.si.ws.WSDLReference;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Deleted:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -1,199 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.soa.bpel.runtime.ws;
-
-import javassist.*;
-import javassist.bytecode.AnnotationsAttribute;
-import javassist.bytecode.ClassFile;
-import javassist.bytecode.ConstPool;
-import javassist.bytecode.annotation.Annotation;
-import javassist.bytecode.annotation.EnumMemberValue;
-import javassist.bytecode.annotation.StringMemberValue;
-
-import javax.xml.namespace.QName;
-
-/**
- * Creates JAX-WS Provider classes using javassist.
- * These provider classes can then be deployed to JBossWS in memory.<p>
- * The javassist generated class basically just carries the meta data,
- * while the actual implementation resides in {@link
org.jboss.soa.bpel.runtime.ws.BaseWebServiceEndpoint}
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class WebServiceProviderFactory
-{
- private final static String PKG_PREFIX =
WebServiceProviderFactory.class.getPackage().getName()+".generated.";
-
- public BaseWebServiceEndpoint createProvider(
- QName service, String port,
- String endpointId,
- WSDLReference wsdlRef,
- ClassLoader loader,
- java.io.File handlerFile
- )
- throws Exception
- {
- ClassPool pool = new ClassPool(true);
- pool.appendClassPath(new LoaderClassPath(loader));
-
- // Imports
- pool.importPackage("java.lang");
- pool.importPackage("javax.xml.ws");
- pool.importPackage("javax.jws");
-
- CtClass stringType = pool.get("java.lang.String");
-
- String implClassName = PKG_PREFIX+"BPELWebServiceEndpoint_"+endpointId;
- //CtClass impl = pool.makeClass(implClassName);
-
- // Load an existing class representing the template for a Web Service provider
- // This was necessary, as javassist does not provide a way to set an implemented
- // interface that supports generics. Although the super class
(AbstractWebServiceEndpoint)
- // implements this Provider<SOAPMessage> interface, CXF requires the actual web
service
- // implementation class to directly define this interface. (RIFTSAW-123)
- CtClass impl =
pool.get("org.jboss.soa.bpel.runtime.ws.TemplateWebServiceEndpoint");
- impl.setName(implClassName);
-
- // AbstractWebServiceEndpoint.endpointId property
- CtField idField = new CtField(stringType, "endpointId", impl);
- idField.setModifiers(Modifier.PUBLIC);
- impl.addField(idField, "\""+endpointId+"\"");
-
- // AbstractWebServiceEndpoint.serviceName property
- CtField serviceField = new CtField(stringType, "serviceName", impl);
- serviceField.setModifiers(Modifier.PUBLIC);
- impl.addField(serviceField,
"\""+service.toString()+"\"");
-
- // AbstractWebServiceEndpoint.wsdlLocation property
- CtField wsdlLocationField = new CtField(stringType, "wsdlLocation", impl);
- wsdlLocationField.setModifiers(Modifier.PUBLIC);
- impl.addField(wsdlLocationField,
"\""+wsdlRef.getWsdlURL().toExternalForm()+"\"");
-
- // AbstractWebServiceEndpoint.portName property
- CtField portNameField = new CtField(stringType, "portName", impl);
- portNameField.setModifiers(Modifier.PUBLIC);
- impl.addField(portNameField, "\""+port+"\"");
-
- // Annotations
- ClassFile classFile = impl.getClassFile();
- classFile.setVersionToJava5();
- ConstPool constantPool = classFile.getConstPool();
-
- /*
- @WebServiceProvider(
- portName="HelloPort",
- serviceName="HelloService",
-
targetNamespace="http://helloservice.org/wsdl",
- wsdlLocation="WEB-INF/wsdl/HelloService.wsdl"
- )
- @ServiceMode(value=Service.Mode.MESSAGE)
- */
- AnnotationsAttribute attr = new
- AnnotationsAttribute(constantPool, AnnotationsAttribute.visibleTag);
-
- // --
- Annotation providerAnnotation = new Annotation(
- "javax.xml.ws.WebServiceProvider", constantPool);
-
- providerAnnotation.addMemberValue(
- "serviceName",
- new StringMemberValue(service.getLocalPart(), constantPool)
- );
- providerAnnotation.addMemberValue(
- "portName",
- new StringMemberValue(port, constantPool)
- );
- providerAnnotation.addMemberValue(
- "targetNamespace",
- new StringMemberValue(service.getNamespaceURI(), constantPool)
- );
- providerAnnotation.addMemberValue(
- "wsdlLocation",
- new StringMemberValue(wsdlRef.getWsdlURL().toExternalForm(), constantPool)
- );
- attr.addAnnotation(providerAnnotation);
-
- // --
- Annotation annotation2 = new Annotation("javax.xml.ws.ServiceMode",
- constantPool);
- EnumMemberValue enumValue = new EnumMemberValue(constantPool);
- enumValue.setType("javax.xml.ws.Service$Mode");
- enumValue.setValue("MESSAGE");
- annotation2.addMemberValue("value", enumValue);
-
- attr.addAnnotation(annotation2);
-
- classFile.addAttribute(attr);
-
-
- // Check if handler chain should be established
- if (handlerFile != null) {
- Annotation handlerChain = new Annotation("javax.jws.HandlerChain",
constantPool);
-
- handlerChain.addMemberValue("file",
- new StringMemberValue("/"+handlerFile.getName(), constantPool));
-
- attr.addAnnotation(handlerChain);
- }
-
-
- createStringGetter(impl, stringType, "endpointId",
"getEndpointId");
- createStringGetter(impl, stringType, "serviceName",
"getServiceName");
- createStringGetter(impl, stringType, "wsdlLocation",
"getWsdlLocation");
- createStringGetter(impl, stringType, "portName", "getPortName");
-
- // ------------
-
- // freeze
- impl.stopPruning(false);
- impl.toClass(loader);
- JavaUtils.clearBlacklists(loader);
-
- // test it
- Class clazz = loader.loadClass(implClassName);
-
- BaseWebServiceEndpoint obj = (BaseWebServiceEndpoint)clazz.newInstance();
-
- return obj;
- }
-
- private void createStringGetter(CtClass impl, CtClass stringType, String property,
String methodName)
- throws Exception
- {
- CtMethod method = new CtMethod(
- stringType, methodName,
- new CtClass[]{},
- impl
- );
-
- // Method body
- StringBuffer body = new StringBuffer();
- body.append("{");
- body.append("return this."+property+";");
- body.append("}");
-
- method.setBody(body.toString());
-
- impl.addMethod(method);
-
- }
-}
Copied: trunk/runtime/engine/src/main/java/org/jboss/soa/si/InvocationAdapter.java (from
rev 1038,
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/InvocationAdapter.java)
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/InvocationAdapter.java
(rev 0)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/si/InvocationAdapter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.soa.si;
+
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.jboss.soa.bpel.runtime.engine.BPELEngine;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Hides the message translation details when invoking ODE from
+ * an external component (i.e. ESB or WS).
+ *
+ * @see org.jboss.soa.bpel.runtime.engine.BPELEngine#invoke(InvocationAdapter)
+ *
+ * @author Heiko Braun <hbraun(a)redhat.com>
+ */
+public interface InvocationAdapter<T>
+{
+ String getOperationName();
+ QName getServiceName();
+ String getPortName();
+
+ /**
+ * Callback from the Engine towards the adapter when
+ * turning an external message representation into an ODE request {@link
org.apache.ode.bpel.iapi.Message}
+ * @param mex
+ * @param odeRequest
+ */
+ void parseRequest(MyRoleMessageExchange mex, Message odeRequest);
+
+ /**
+ * Callback from the Engine towards the adapter when
+ * turning an ODE response {@link org.apache.ode.bpel.iapi.Message} into an external
format <T>
+ * @param mex
+ */
+ void createResponse(MyRoleMessageExchange mex);
+
+ void createFault(MyRoleMessageExchange mex);
+ /**
+ * Access the invocation result (response)
+ * @return T
+ */
+ T getInvocationResult();
+
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ServiceInvoker.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ServiceInvoker.java
(rev 0)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/si/ServiceInvoker.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. 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.jboss.soa.si;
+
+
+public interface ServiceInvoker {
+
+ /**
+ * This method initializes the service invoker. This method must
+ * be called before using the invoker.
+ *
+ * @throws Exception Failed to initialize
+ */
+ public void init() throws Exception;
+
+ /**
+ * This method invokes the associated service using the invocation
+ * adapter supplied.
+ *
+ * @param invocationAdapter The invocation adapter
+ * @throws Exception Failed to invoke the service
+ */
+ public void invoke(InvocationAdapter<?> invocationAdapter) throws Exception;
+
+ /**
+ * This method closes the service invoker.
+ *
+ * @throws Exception Failed to close
+ */
+ public void close() throws Exception;
+
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/BaseWebServiceEndpoint.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/BaseWebServiceEndpoint.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/BaseWebServiceEndpoint.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.soa.bpel.runtime.ws.ODEWebServiceFactory;
+import org.jboss.soa.bpel.runtime.ws.WSInvocationAdapter;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.soap.*;
+import javax.xml.ws.Provider;
+
+/**
+ * Base class for BPEL endpoints that are created through javassist.
+ * Represents a JAX-WS {@link javax.xml.ws.Provider} implementation.
+ *
+ * @see org.jboss.soa.si.ws.WebServiceProviderFactory
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class BaseWebServiceEndpoint implements Provider<SOAPMessage>
+{
+ protected final Log log = LogFactory.getLog(getClass());
+
+ private SOAPMessageAdapter soapAdapter;
+ private QName serviceQName;
+ private Definition wsdlDefinition;
+ private WebServiceFactory serviceFactory;
+
+ private boolean isInitialized;
+
+ private void init()
+ {
+ if(!isInitialized)
+ {
+ try
+ {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ this.wsdlDefinition = wsdlReader.readWSDL(getWsdlLocation());
+ this.serviceQName = QName.valueOf(getServiceName());
+ this.soapAdapter = new SOAPMessageAdapter(wsdlDefinition, serviceQName,
getPortName());
+
+ this.serviceFactory = new ODEWebServiceFactory();
+ }
+ catch (WSDLException e)
+ {
+ throw new RuntimeException("Failed to parse WSDL", e);
+ }
+ isInitialized = true;
+ }
+ }
+
+ public SOAPMessage invoke(SOAPMessage soapMessage)
+ {
+ log.debug("Invoking endpoint "+getEndpointId());
+ init();
+
+ try
+ {
+ SOAPPart soapPart = soapMessage.getSOAPPart();
+ SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
+ Element messageElement = getMessagePayload(soapEnvelope);
+
+ if(log.isDebugEnabled())
+ log.debug( "ODE inbound message: \n" +DOMWriter.printNode(soapEnvelope,
true) );
+
+ // Create invocation context
+ final String operationName = resolveOperationName(messageElement);
+
+ WSInvocationAdapter invocationContext =
serviceFactory.getInvocationAdapter(operationName,
+ serviceQName, getPortName(), soapAdapter);
+
+ invocationContext.setSOAPMessage(soapMessage);
+
+ // Invoke ODE
+ serviceFactory.getServiceInvoker().invoke(invocationContext);
+
+ // Handle response
+ SOAPMessage responseMessage = null;
+
+ if (isResponseExpected(messageElement)) {
+ responseMessage = invocationContext.getInvocationResult();
+
+ if(log.isDebugEnabled())
+ log.debug( "ODE outbound message: \n" +
+ DOMWriter.printNode(responseMessage.getSOAPPart().getEnvelope(), true)
+ );
+ } else if (log.isDebugEnabled()) {
+ log.debug( "ODE no outbound message");
+ }
+
+ if (responseMessage == null) {
+ log.debug("No response, probably due to oneway request");
+
+ // Need to create an empty response to avoid npe in jbossws (RIFTSAW-154)
+ responseMessage = MessageFactory.newInstance().createMessage();
+ }
+
+ return responseMessage;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to invoke BPEL process:
"+e.getMessage(), e);
+ }
+ }
+
+ public String resolveOperationName(Element payload)
+ {
+ if(soapAdapter.isRPC())
+ {
+ return payload.getLocalName();
+ }
+ else
+ {
+ QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
+ Operation op = new WSDLParser(wsdlDefinition).getDocLitOperation(
+ this.serviceQName, getPortName(), elementName
+ );
+
+ return op.getName();
+ }
+ }
+
+ public boolean isResponseExpected(Element payload)
+ {
+ Operation op=null;
+
+ if(soapAdapter.isRPC())
+ {
+ QName elementName = new QName(payload.getNamespaceURI(),
payload.getLocalName());
+ op = new WSDLParser(wsdlDefinition).getRPCOperation(
+ this.serviceQName, getPortName(), elementName
+ );
+ }
+ else
+ {
+ QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
+ op = new WSDLParser(wsdlDefinition).getDocLitOperation(
+ this.serviceQName, getPortName(), elementName
+ );
+ }
+
+ if (op == null) {
+ throw new RuntimeException("Failed to locate operation definition for:
"+payload);
+ }
+
+ return op.getOutput() != null;
+ }
+
+ public static Element getMessagePayload(SOAPEnvelope soapEnvelope)
+ throws SOAPException
+ {
+ SOAPBody body = soapEnvelope.getBody();
+ Element messageElement = null; // first child of type Element
+ NodeList children = body.getChildNodes();
+ for(int i=0; i<children.getLength(); i++)
+ {
+ Node tmp = children.item(i);
+ if(Node.ELEMENT_NODE == tmp.getNodeType())
+ {
+ messageElement = (Element)tmp;
+ break;
+ }
+ }
+ return messageElement;
+ }
+
+ public String getEndpointId() {
+ return(null);
+ }
+
+ public String getServiceName() {
+ return(null);
+ }
+
+ public String getWsdlLocation() {
+ return(null);
+ }
+
+ public String getPortName() {
+ return(null);
+ }
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/DOMWriter.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/DOMWriter.java
(rev 0)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/DOMWriter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,656 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (
http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache
Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <
http://www.apache.org/>.
+ */
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Traverse a DOM tree in order to print a document that is parsed.
+ *
+ * @author Andy Clark, IBM
+ * @author Thomas.Diesler(a)jboss.org
+ */
+@SuppressWarnings("unchecked")
+public class DOMWriter
+{
+ // Print writer
+ private PrintWriter out;
+ // True, if canonical output
+ private boolean canonical;
+ // True, if pretty printing should be used
+ private boolean prettyprint;
+ // True, if the XML declaration should be written
+ private boolean writeXMLDeclaration;
+ // True, if whitespace should be ignored
+ private boolean ignoreWhitespace;
+ // Explicit character set encoding
+ private String charsetName;
+ // indent for the pretty printer
+ private int prettyIndent;
+ // True, if the XML declaration has been written
+ private boolean wroteXMLDeclaration;
+ // The node that started the write
+ private Node rootNode;
+ // True if we want namespace completion
+ private boolean completeNamespaces = true;
+ // The current default namespace
+ private String currentDefaultNamespace;
+
+ public DOMWriter(Writer w)
+ {
+ this.out = new PrintWriter(w);
+ }
+
+ public DOMWriter(Writer w, String charsetName)
+ {
+ this.out = new PrintWriter(w);
+ this.charsetName = charsetName;
+ this.writeXMLDeclaration = true;
+ }
+
+ public DOMWriter(OutputStream stream)
+ {
+ try
+ {
+ this.out = new PrintWriter(new OutputStreamWriter(stream, "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // ignore, UTF-8 should be available
+ }
+ }
+
+ public DOMWriter(OutputStream stream, String charsetName)
+ {
+ try
+ {
+ this.out = new PrintWriter(new OutputStreamWriter(stream, charsetName));
+ this.charsetName = charsetName;
+ this.writeXMLDeclaration = true;
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new IllegalArgumentException("Unsupported encoding: " +
charsetName);
+ }
+ }
+
+ /**
+ * Print a node with explicit prettyprinting.
+ * The defaults for all other DOMWriter properties apply.
+ *
+ */
+ public static String printNode(Node node, boolean prettyprint)
+ {
+ StringWriter strw = new StringWriter();
+ new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
+ return strw.toString();
+ }
+
+ public boolean isCanonical()
+ {
+ return canonical;
+ }
+
+ /**
+ * Set wheter entities should appear in their canonical form.
+ * The default is false.
+ */
+ public DOMWriter setCanonical(boolean canonical)
+ {
+ this.canonical = canonical;
+ return this;
+ }
+
+ public boolean isIgnoreWhitespace()
+ {
+ return ignoreWhitespace;
+ }
+
+ /**
+ * Set whether whitespace should be ignored.
+ * The default is false.
+ */
+ public DOMWriter setIgnoreWhitespace(boolean ignoreWhitespace)
+ {
+ this.ignoreWhitespace = ignoreWhitespace;
+ return this;
+ }
+
+ /**
+ * Set wheter subelements should have their namespaces completed.
+ * Setting this to false may lead to invalid XML fragments.
+ * The default is true.
+ */
+ public DOMWriter setCompleteNamespaces(boolean complete)
+ {
+ this.completeNamespaces = complete;
+ return this;
+ }
+
+ public boolean isPrettyprint()
+ {
+ return prettyprint;
+ }
+
+ /**
+ * Set wheter element should be indented.
+ * The default is false.
+ */
+ public DOMWriter setPrettyprint(boolean prettyprint)
+ {
+ this.prettyprint = prettyprint;
+ return this;
+ }
+
+ public boolean isWriteXMLDeclaration()
+ {
+ return writeXMLDeclaration;
+ }
+
+ /**
+ * Set wheter the XML declaration should be written.
+ * The default is false.
+ */
+ public DOMWriter setWriteXMLDeclaration(boolean flag)
+ {
+ this.writeXMLDeclaration = flag;
+ return this;
+ }
+
+ public void print(Node node)
+ {
+ if (prettyprint && ignoreWhitespace)
+ throw new IllegalStateException("Cannot pretty print and ignore
whitespace");
+
+ rootNode = node;
+ printInternal(node, false);
+ }
+
+ private void printInternal(Node node, boolean indentEndMarker)
+ {
+ // is there anything to do?
+ if (node == null)
+ {
+ return;
+ }
+
+ // JBAS-2117 - Don't skip the DOCUMENT_NODE
+ // if (node instanceof Document) node = ((Document)node).getDocumentElement();
+
+ if (wroteXMLDeclaration == false && writeXMLDeclaration == true &&
canonical == false)
+ {
+ out.print("<?xml version='1.0'");
+ if (charsetName != null)
+ out.print(" encoding='" + charsetName + "'");
+
+ out.print("?>");
+ if (prettyprint)
+ out.println();
+
+ wroteXMLDeclaration = true;
+ }
+
+ int type = node.getNodeType();
+ boolean hasChildNodes = node.getChildNodes().getLength() > 0;
+
+ String nodeName = node.getNodeName();
+ switch (type)
+ {
+ // print document
+ case Node.DOCUMENT_NODE:
+ {
+ NodeList children = node.getChildNodes();
+ int len = children.getLength();
+ for (int iChild = 0; iChild < len; iChild++)
+ {
+ printInternal(children.item(iChild), false);
+ }
+ out.flush();
+ break;
+ }
+
+ // print element with attributes
+ case Node.ELEMENT_NODE:
+ {
+ Element element = (Element)node;
+ if (prettyprint)
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+ prettyIndent++;
+ }
+
+ out.print('<');
+ out.print(nodeName);
+
+ Map nsMap = new HashMap();
+ String elPrefix = node.getPrefix();
+ String elNamespaceURI = node.getNamespaceURI();
+ if (elPrefix != null)
+ {
+ String nsURI = getNamespaceURI(elPrefix, element, rootNode);
+ nsMap.put(elPrefix, nsURI);
+ }
+
+ Attr attrs[] = sortAttributes(node.getAttributes());
+ for (int i = 0; i < attrs.length; i++)
+ {
+ Attr attr = attrs[i];
+ String atPrefix = attr.getPrefix();
+ String atName = attr.getNodeName();
+ String atValue = normalize(attr.getNodeValue(), canonical);
+
+ if (atName.equals("xmlns"))
+ currentDefaultNamespace = atValue;
+
+ if (atPrefix != null && !atPrefix.equals("xmlns")
&& !atPrefix.equals("xml"))
+ {
+ String nsURI = getNamespaceURI(atPrefix, element, rootNode);
+ nsMap.put(atPrefix, nsURI);
+ // xsi:type='ns1:SubType', xsi:type='xsd:string'
+ if (atName.equals(atPrefix + ":type") &&
atValue.indexOf(":") > 0)
+ {
+ // xsi defined on the envelope
+ if (nsURI == null)
+ nsURI = getNamespaceURI(atPrefix, element, null);
+
+ if
("http://www.w3.org/2001/XMLSchema-instance".equals(nsURI))
+ {
+ String typePrefix = atValue.substring(0,
atValue.indexOf(":"));
+ String typeURI = getNamespaceURI(typePrefix, element, rootNode);
+ nsMap.put(typePrefix, typeURI);
+ }
+ }
+ }
+
+ out.print(" " + atName + "='" + atValue +
"'");
+ }
+
+ // Add namespace declaration for prefixes
+ // that are defined further up the tree
+ if (completeNamespaces)
+ {
+ Iterator itPrefix = nsMap.keySet().iterator();
+ while (itPrefix.hasNext())
+ {
+ String prefix = (String)itPrefix.next();
+ String nsURI = (String)nsMap.get(prefix);
+ if (nsURI == null)
+ {
+ nsURI = getNamespaceURI(prefix, element, null);
+ out.print(" xmlns:" + prefix + "='" + nsURI
+ "'");
+ }
+ }
+ }
+
+ // The SAX ContentHandler will by default not add the namespace declaration
+ // <Hello xmlns='http://somens'>World</Hello>
+ if (elPrefix == null && elNamespaceURI != null)
+ {
+ String defaultNamespace = element.getAttribute("xmlns");
+ if (defaultNamespace.length() == 0 &&
!elNamespaceURI.equals(currentDefaultNamespace))
+ {
+ out.print(" xmlns='" + elNamespaceURI +
"'");
+ currentDefaultNamespace = elNamespaceURI;
+ }
+ }
+
+ if (hasChildNodes)
+ {
+ out.print('>');
+ }
+
+ // Find out if the end marker is indented
+ indentEndMarker = isEndMarkerIndented(node);
+
+ if (indentEndMarker)
+ {
+ out.print('\n');
+ }
+
+ NodeList childNodes = node.getChildNodes();
+ int len = childNodes.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node childNode = childNodes.item(i);
+ printInternal(childNode, false);
+ }
+ break;
+ }
+
+ // handle entity reference nodes
+ case Node.ENTITY_REFERENCE_NODE:
+ {
+ if (canonical)
+ {
+ NodeList children = node.getChildNodes();
+ if (children != null)
+ {
+ int len = children.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ printInternal(children.item(i), false);
+ }
+ }
+ }
+ else
+ {
+ out.print('&');
+ out.print(nodeName);
+ out.print(';');
+ }
+ break;
+ }
+
+ // print cdata sections
+ case Node.CDATA_SECTION_NODE:
+ {
+ if (canonical)
+ {
+ out.print(normalize(node.getNodeValue(), canonical));
+ }
+ else
+ {
+ out.print("<![CDATA[");
+ out.print(node.getNodeValue());
+ out.print("]]>");
+ }
+ break;
+ }
+
+ // print text
+ case Node.TEXT_NODE:
+ {
+ String text = normalize(node.getNodeValue(), canonical);
+ if (text.trim().length() > 0)
+ {
+ out.print(text);
+ }
+ else if (prettyprint == false && ignoreWhitespace == false)
+ {
+ out.print(text);
+ }
+ break;
+ }
+
+ // print processing instruction
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ {
+ out.print("<?");
+ out.print(nodeName);
+ String data = node.getNodeValue();
+ if (data != null && data.length() > 0)
+ {
+ out.print(' ');
+ out.print(data);
+ }
+ out.print("?>");
+ break;
+ }
+
+ // print comment
+ case Node.COMMENT_NODE:
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+
+ out.print("<!--");
+ String data = node.getNodeValue();
+ if (data != null)
+ {
+ out.print(data);
+ }
+ out.print("-->");
+
+ if (prettyprint)
+ {
+ out.print('\n');
+ }
+
+ break;
+ }
+ }
+
+ if (type == Node.ELEMENT_NODE)
+ {
+ if (prettyprint)
+ prettyIndent--;
+
+ if (hasChildNodes == false)
+ {
+ out.print("/>");
+ }
+ else
+ {
+ if (indentEndMarker)
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+ }
+
+ out.print("</");
+ out.print(nodeName);
+ out.print('>');
+ }
+
+ if (prettyIndent > 0)
+ {
+ out.print('\n');
+ }
+ }
+ out.flush();
+ }
+
+ private String getNamespaceURI(String prefix, Element element, Node stopNode)
+ {
+ Node parent = element.getParentNode();
+ String nsURI = element.getAttribute("xmlns:" + prefix);
+ if (nsURI.length() == 0 && element != stopNode && parent instanceof
Element)
+ return getNamespaceURI(prefix, (Element)parent, stopNode);
+
+ return (nsURI.length() > 0 ? nsURI : null);
+ }
+
+ private boolean isEndMarkerIndented(Node node)
+ {
+ if (prettyprint)
+ {
+ NodeList childNodes = node.getChildNodes();
+ int len = childNodes.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node children = childNodes.item(i);
+ if (children.getNodeType() == Node.ELEMENT_NODE)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /** Returns a sorted list of attributes. */
+ private Attr[] sortAttributes(NamedNodeMap attrs)
+ {
+
+ int len = (attrs != null) ? attrs.getLength() : 0;
+ Attr array[] = new Attr[len];
+ for (int i = 0; i < len; i++)
+ {
+ array[i] = (Attr)attrs.item(i);
+ }
+ for (int i = 0; i < len - 1; i++)
+ {
+ String name = array[i].getNodeName();
+ int index = i;
+ for (int j = i + 1; j < len; j++)
+ {
+ String curName = array[j].getNodeName();
+ if (curName.compareTo(name) < 0)
+ {
+ name = curName;
+ index = j;
+ }
+ }
+ if (index != i)
+ {
+ Attr temp = array[i];
+ array[i] = array[index];
+ array[index] = temp;
+ }
+ }
+ return (array);
+ }
+
+ /** Normalizes the given string. */
+ public static String normalize(String s, boolean canonical)
+ {
+ int len = (s != null) ? s.length() : 0;
+ StringBuilder str = new StringBuilder();
+
+ for (int i = 0; i < len; i++)
+ {
+ char ch = s.charAt(i);
+ switch (ch)
+ {
+ case '<':
+ {
+ str.append("<");
+ break;
+ }
+ case '>':
+ {
+ str.append(">");
+ break;
+ }
+ case '&':
+ {
+ str.append("&");
+ break;
+ }
+ case '"':
+ {
+ str.append(""");
+ break;
+ }
+ case '\'':
+ {
+ str.append("'");
+ break;
+ }
+ case '\r':
+ case '\n':
+ {
+ if (canonical)
+ {
+ str.append("&#");
+ str.append(Integer.toString(ch));
+ str.append(';');
+ break;
+ }
+ // else, default append char
+ }
+ default:
+ {
+ str.append(ch);
+ }
+ }
+ }
+ return (str.toString());
+ }
+}
\ No newline at end of file
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/JavaUtils.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/JavaUtils.java
(rev 0)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/JavaUtils.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Method;
+
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ * @author Jeff Yu <cyu(a)redhat.com>
+ */
+public class JavaUtils
+{
+ protected static final Log log = LogFactory.getLog(JavaUtils.class);
+
+ public static boolean isJBossRepositoryClassLoader(ClassLoader loader)
+ {
+ Class clazz = loader.getClass();
+ while (!clazz.getName().startsWith("java"))
+ {
+ if
("org.jboss.mx.loading.RepositoryClassLoader".equals(clazz.getName()))
+ return true;
+ clazz = clazz.getSuperclass();
+ }
+
+ return false;
+ }
+
+ /**
+ * Clears black lists on a JBoss RepositoryClassLoader. This is somewhat of a hack,
and
+ * could be replaced with an integration module. This is needed when the following
order of
+ * events occur.
+ *
+ * <ol>
+ * <li>loadClass() returns not found</li>
+ * <li>Some call to defineClass()</li>
+ * <ol>
+ *
+ * The CNFE triggers a black list addition, which cause the class never again to be
found.
+ *
+ * @param loader the loader to clear black lists for
+ */
+ public static void clearBlacklists(ClassLoader loader)
+ {
+ if (isJBossRepositoryClassLoader(loader))
+ {
+ for(Method m : loader.getClass().getMethods())
+ {
+ if("clearBlackLists".equalsIgnoreCase(m.getName()))
+ {
+ try
+ {
+ m.invoke(loader);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Convert the SoapMessage object into String.
+ * @param soapMessage
+ * @return
+ */
+ public static String getSoapMessageASString(SOAPMessage soapMessage) {
+ try {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ soapMessage.writeTo(outputStream);
+ byte[] byteArray = outputStream.toByteArray();
+ String soapMsg = new String( byteArray, "UTF-8");
+ return soapMsg;
+ } catch (Exception e) {
+ log.error("Error in converting SOAPMessage into String");
+ }
+ return null;
+ }
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/SOAPMessageAdapter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,644 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.wsdl.WsdlUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.wsdl.*;
+import javax.wsdl.extensions.ElementExtensible;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPHeader;
+import javax.xml.namespace.QName;
+import javax.xml.soap.*;
+
+import java.util.*;
+
+/**
+ * Adopts {@link javax.xml.soap.SOAPMessage}'s to ODE's internal
+ * {@link org.apache.ode.bpel.iapi.Message} representation and vice versa.
+ *
+ * @see org.jboss.soa.bpel.runtime.ws.WebServiceClient
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class SOAPMessageAdapter
+{
+ protected final Log log = LogFactory.getLog(getClass());
+
+ private Definition wsdl;
+ private QName serviceName;
+
+ private String portName;
+ private Service serviceDef;
+ private Binding binding;
+
+ private Port port;
+ private boolean isRPC;
+
+ private SOAPBinding soapBinding;
+
+ private SOAPFactory soapFactory;
+
+ public SOAPMessageAdapter(Definition wsdl, QName serviceName, String portName)
+ {
+ this.wsdl = wsdl;
+ this.serviceName = serviceName;
+ this.portName = portName;
+
+ serviceDef = wsdl.getService(serviceName);
+ if (serviceDef == null)
+ throw new RuntimeException("Service not found "+serviceName);
+
+ port = serviceDef.getPort(portName);
+ if (port == null)
+ throw new RuntimeException("Port '"+portName+"' not found on
service: "+serviceName);
+
+ binding = port.getBinding();
+ if (binding == null)
+ throw new RuntimeException("No binding for port "+portName);
+
+ if (!WsdlUtils.useSOAPBinding(port)) {
+ throw new RuntimeException("No SOAP binding for port"+portName);
+ }
+ soapBinding = (SOAPBinding) WsdlUtils.getBindingExtension(port);
+
+
+ String style = soapBinding.getStyle();
+ isRPC = style != null && style.equals("rpc");
+
+ try
+ {
+ this.soapFactory = SOAPFactory.newInstance();
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * This method creates the SOAP request and returns the SOAPAction field.
+ *
+ * @param soapMessage
+ * @param odeRequestMessage
+ * @param wsdlOperation
+ * @return The SOAP action
+ */
+ public String createSoapRequest(SOAPMessage soapMessage, Message odeRequestMessage,
Operation wsdlOperation)
+ {
+ String ret=null;
+
+ BindingOperation bop = binding.getBindingOperation(wsdlOperation.getName(), null,
null);
+ if (bop == null)
+ throw new RuntimeException("Operation "+wsdlOperation.getName()+"not
found on "+serviceName+"/"+portName);
+
+ BindingInput bi = bop.getBindingInput();
+ if (bi == null)
+ throw new RuntimeException("Binding input not found on
"+serviceName+"/"+portName);
+
+ // Headers
+ createSoapHeaders(
+ soapMessage,
+ getSOAPHeaders(bi),
+ wsdlOperation.getInput().getMessage(),
+ odeRequestMessage.getHeaderParts(),
+ odeRequestMessage.getMessage()
+ );
+
+
+ // SOAP Body
+ javax.wsdl.extensions.soap.SOAPBody wsdlSoapBody = getSOAPBody(bi);
+
+ createSoapBody(
+ soapMessage,
+ wsdlSoapBody,
+ wsdlOperation.getInput().getMessage(),
+ odeRequestMessage.getMessage(),
+ wsdlOperation.getName()
+ );
+
+ // Discover SOAPAction
+ for (Object extension : bop.getExtensibilityElements()) {
+ if (extension instanceof javax.wsdl.extensions.soap.SOAPOperation) {
+ javax.wsdl.extensions.soap.SOAPOperation soapop=
+ (javax.wsdl.extensions.soap.SOAPOperation)extension;
+
+ if (soapop.getSoapActionURI() != null) {
+ ret = soapop.getSoapActionURI();
+ break;
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ public boolean isRPC()
+ {
+ return isRPC;
+ }
+
+ public void createSoapResponse(SOAPMessage soapMessage, Message odeResponseMessage,
Operation wsdlOperation)
+ {
+
+ BindingOperation bop =
binding.getBindingOperation(wsdlOperation.getName(),null,null);
+ if (bop == null)
+ throw new RuntimeException("Operation "+wsdlOperation.getName()+"not
found on "+serviceName+"/"+portName);
+
+ BindingOutput bo = bop.getBindingOutput();
+ if (bo == null)
+ throw new RuntimeException("Binding output not found on
"+serviceName+"/"+portName);
+
+ // Headers
+ if (odeResponseMessage.getHeaderParts().size() > 0 || getSOAPHeaders(bo).size()
> 0)
+ createSoapHeaders(
+ soapMessage,
+ getSOAPHeaders(bo),
+ wsdlOperation.getOutput().getMessage(),
+ odeResponseMessage.getHeaderParts(),
+ odeResponseMessage.getMessage()
+ );
+
+
+ // SOAP Body
+ javax.wsdl.extensions.soap.SOAPBody wsdlSOAPBody = getSOAPBody(bo);
+ createSoapBody(
+ soapMessage,
+ wsdlSOAPBody,
+ wsdlOperation.getOutput().getMessage(),
+ odeResponseMessage.getMessage(),
+ wsdlOperation.getName() + "Response"
+ );
+
+ }
+
+ private void createSoapBody(SOAPMessage soapMessage,
+ javax.wsdl.extensions.soap.SOAPBody wsdlSoapBody,
javax.wsdl.Message wsdlMessageDef,
+ Element message, String operationName)
+ {
+ try
+ {
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+
+ SOAPElement partHolder = null;
+ if(isRPC)
+ {
+ partHolder = soapFactory.createElement(new QName(wsdlSoapBody.getNamespaceURI(),
operationName, "odens"));
+ }
+ else
+ {
+ partHolder = soapBody;
+ }
+
+ List<Part> parts = wsdlMessageDef.getOrderedParts(wsdlSoapBody.getParts());
+ for(Part part : parts)
+ {
+ Element srcPartEl = DOMUtils.findChildByName(message, new QName(null,
part.getName()));
+ if (srcPartEl == null)
+ throw new RuntimeException("Part is missing: " +part.getName());
+
+ SOAPElement partElement = soapFactory.createElement(srcPartEl);
+ if (isRPC)
+ {
+ partHolder.addChildElement(partElement);
+ }
+ else
+ {
+ for (Iterator<SOAPElement> i = partElement.getChildElements();
i.hasNext();) partHolder.addChildElement(i.next());
+ }
+ }
+
+ // late bind
+ if(isRPC)
+ soapBody.addChildElement(partHolder);
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to create soap body",e);
+ }
+ }
+
+ private void createSoapHeaders(SOAPMessage soapMessage, List<SOAPHeader>
headers,
+ javax.wsdl.Message wsdlMessageDef,
+ Map<String, Node> headerParts, Element message)
+ {
+ try {
+ javax.xml.soap.SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ if (soapHeader==null) soapHeader =
soapMessage.getSOAPPart().getEnvelope().addHeader();
+ for (Node headerNode : headerParts.values()) {
+ //like we may have password header with null value.
+ if(headerNode == null){
+ continue;
+ }
+ if (Node.ELEMENT_NODE == headerNode.getNodeType()) {
+ if (getFirstChildWithName(new QName(headerNode.getNamespaceURI(),
headerNode.getLocalName()),soapHeader) == null) {
+ SOAPElement partElement = soapFactory.createElement((Element) headerNode);
+ soapHeader.addChildElement(partElement);
+ }
+ } else {
+ throw new RuntimeException("SOAP header must be a node_element " +
headerNode);
+ }
+ }
+
+ //Add soap header according to binding.
+ for (SOAPHeader header : headers) {
+ Element headerEl = DOMUtils.findChildByName(message, new QName(null,
header.getPart()));
+ if (headerEl != null) {
+
+ // RIFTSAW-305 - don't think the part name should be added to the SOAP header
+ //SOAPElement soapHeaderEl = soapFactory.createElement(new
QName(header.getMessage().getNamespaceURI(), header.getPart(),"odens"));
+ NodeList list = headerEl.getChildNodes();
+ for(int i=0; i< list.getLength(); i++) {
+ SOAPElement partElement = soapFactory.createElement((Element)list.item(i));
+ soapHeader.addChildElement(partElement);
+ }
+ //soapHeader.addChildElement(soapHeaderEl);
+ }
+ }
+ } catch (SOAPException e) {
+ throw new RuntimeException("Failed to create soap header",e);
+ }
+ }
+
+ public void parseSoapResponse(org.apache.ode.bpel.iapi.Message odeMessage,
+ SOAPMessage soapMessage, javax.wsdl.Operation
odeOperation) {
+ BindingOperation bop = binding.getBindingOperation(odeOperation.getName(), null,
null);
+ if (bop == null)
+ throw new RuntimeException("Operation "+odeOperation.getName()+"not
found on "+serviceName+"/"+portName);
+
+ BindingOutput bo = bop.getBindingOutput();
+ if (bo == null)
+ throw new RuntimeException("Binding output not found on
"+serviceName+"/"+portName);
+
+ extractSoapBodyParts(odeMessage, soapMessage, getSOAPBody(bo),
odeOperation.getOutput().getMessage(), odeOperation.getName() + "Response");
+ extractSoapHeaderParts(odeMessage, soapMessage, getSOAPHeaders(bo),
odeOperation.getOutput().getMessage());
+ }
+
+ public void parseSoapRequest(
+ org.apache.ode.bpel.iapi.Message odeMessage,
+ SOAPMessage soapMessage,
+ Operation op)
+ {
+
+ BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);
+
+ if (bop == null)
+ throw new RuntimeException("Binding operation not found
("+serviceName+"/"+portName);
+
+ BindingInput bi = bop.getBindingInput();
+ if (bi == null)
+ throw new RuntimeException("Binding input not
found"+serviceName+"/"+portName);
+
+ extractSoapBodyParts(odeMessage, soapMessage, getSOAPBody(bi),
op.getInput().getMessage(), op.getName());
+ extractSoapHeaderParts(odeMessage, soapMessage, getSOAPHeaders(bi),
op.getInput().getMessage());
+ }
+
+ public void createSoapFault(SOAPMessage soapMessage, Element message, QName faultName,
Operation op)
+ {
+ try
+ {
+ Element detail = buildSoapDetail(message, faultName, op);
+ SOAPFault fault = soapMessage.getSOAPBody().addFault();
+ fault.setFaultCode(faultName);
+ if(detail!=null)
+ fault.addDetail().addChildElement(soapFactory.createElement(detail));
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to create fault", e);
+ }
+ }
+
+ private Element buildSoapDetail(Element message, QName faultName, Operation op)
+ {
+ if (faultName.getNamespaceURI() == null)
+ return toFaultDetail(faultName, message);
+ if (op == null) {
+ return toFaultDetail(faultName, message);
+ }
+ Fault f = op.getFault(faultName.getLocalPart());
+ if (f == null)
+ return toFaultDetail(faultName, message);
+
+ // For faults, there will be exactly one part.
+ Part p = (Part)f.getMessage().getParts().values().iterator().next();
+ if (p == null)
+ return toFaultDetail(faultName, message);
+ Element partEl= DOMUtils.findChildByName(message,new QName(null,p.getName()));
+ if (partEl == null)
+ return toFaultDetail(faultName, message);
+ Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
+ if (detail == null)
+ return toFaultDetail(faultName, message);
+
+ return detail;
+ }
+
+ private Element toFaultDetail(QName fault, Element message) {
+ if (message == null) return null;
+ Element firstPart = DOMUtils.getFirstChildElement(message);
+ if (firstPart == null) return null;
+ Element detail = DOMUtils.getFirstChildElement(firstPart);
+ if (detail == null) return firstPart;
+ return detail;
+ }
+
+ private void extractSoapHeaderParts(Message odeMessage, SOAPMessage soapMessage,
List<SOAPHeader> headerDefs,javax.wsdl.Message wsdlMessageDef)
+ {
+ try {
+ javax.xml.soap.SOAPHeader soapHeader = soapMessage.getSOAPHeader();
+ // Checking that the definitions we have are at least there
+ for (SOAPHeader headerDef : headerDefs)
+ handleSoapHeaderPartDef(odeMessage, soapHeader, headerDef, wsdlMessageDef);
+
+ // Extracting whatever header elements we find in the message, binding and
abstract parts
+ // aren't reliable enough given what people do out there.
+ if (soapHeader != null) {
+ Iterator headersIter = soapHeader.getChildElements();
+ while (headersIter.hasNext()) {
+ Object obj=headersIter.next();
+
+ // Should be SOAPHeaderElement, but CXF also returns javax.xml.soap.Text
+ // objects aswell
+ if (obj instanceof javax.xml.soap.SOAPHeaderElement) {
+ javax.xml.soap.SOAPHeaderElement headerElem =
(javax.xml.soap.SOAPHeaderElement) obj;
+ String partName = findHeaderPartName(headerDefs,
headerElem.getElementQName());
+ Document doc = DOMUtils.newDocument();
+
+ // RIFTSAW-74 - slight modification to avoid jbossws exception when
reconstructing the
+ // SOAP message.
+
+ //Element destPart = doc.createElementNS(null, partName);
+ //destPart.appendChild(doc.importNode(headerElem, true));
+ //odeMessage.setHeaderPart(partName, destPart);
+ odeMessage.setHeaderPart(partName, (Element)doc.importNode(headerElem, true));
+ }
+ }
+ }
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to extracts header parts",e);
+ }
+ }
+
+ private String findHeaderPartName(List<SOAPHeader> headerDefs, QName elmtName) {
+ for (SOAPHeader headerDef : headerDefs) {
+ javax.wsdl.Message hdrMsg = wsdl.getMessage(headerDef.getMessage());
+ for (Object o : hdrMsg.getParts().values()) {
+ Part p = (Part) o;
+ if (p.getElementName() != null &&
+ p.getElementName().equals(elmtName)) return p.getName();
+ }
+ }
+ return elmtName.getLocalPart();
+ }
+
+ private void handleSoapHeaderPartDef(Message odeMessage, javax.xml.soap.SOAPHeader
header, SOAPHeader headerdef,
+ javax.wsdl.Message msgType) {
+ // Is this header part of the "payload" messsage?
+ boolean payloadMessageHeader = headerdef.getMessage() == null ||
headerdef.getMessage().equals(msgType.getQName());
+ boolean requiredHeader = payloadMessageHeader ||
Boolean.TRUE.equals(headerdef.getRequired());
+
+ if (header == null) {
+ if (requiredHeader)
+ throw new RuntimeException("Soap Header is missing a required field " +
headerdef.getElementType());
+
+ return;
+ }
+
+ javax.wsdl.Message hdrMsg = wsdl.getMessage(headerdef.getMessage());
+ if (hdrMsg == null)
+ return;
+ Part p = hdrMsg.getPart(headerdef.getPart());
+ if (p == null || p.getElementName() == null)
+ return;
+
+ SOAPElement headerEl = getFirstChildWithName(p.getElementName(), header);
+ if (requiredHeader && headerEl == null)
+ throw new RuntimeException("Soap Header is missing a required field "
+ headerdef.getElementType());
+
+ if (headerEl == null) return;
+
+ /* RIFTSAW-127 - this was duplicating the header part in the consolidated (merged)
message stored in the
+ * BPEL process - but this code actually causes two levels of 'part' to be
defined - e.g.
+ * <conversionId><conversationId><details ....
/></conversatioId></conversationId>
+ Document doc = DOMUtils.newDocument();
+ Element destPart = doc.createElementNS(null, p.getName());
+ destPart.appendChild(doc.importNode(headerEl, true));
+ odeMessage.setHeaderPart(p.getName(), destPart);
+ */
+ }
+
+ private void extractSoapBodyParts(
+ Message odeMessage,
+ SOAPMessage soapMessage,
+ javax.wsdl.extensions.soap.SOAPBody wsdlSOAPBody,
+ javax.wsdl.Message wsdlMessageDef, String operationName)
+ {
+ try
+ {
+ SOAPBody soapBody = soapMessage.getSOAPBody();
+ List<Part> parts = wsdlMessageDef.getOrderedParts(wsdlSOAPBody.getParts());
+
+ if(isRPC)
+ {
+ // In RPC the body element is the operation name, wrapping parts. Order
doesn't really matter as far as
+ // we're concerned. All we need to do is copy the soap:body children, since
doc-lit rpc looks the same
+ // in ode and soap.
+
+ QName rpcWrapQName = new QName(wsdlSOAPBody.getNamespaceURI(), operationName);
+ SOAPElement partWrapper = getFirstChildWithName(rpcWrapQName, soapBody);
+
+ if (partWrapper == null)
+ throw new RuntimeException("Expected part wrapper
'"+rpcWrapQName+"'missing on
service:"+serviceName+"/"+portName);
+
+ for(Part part : parts)
+ {
+ SOAPElement srcPart = getFirstChildWithName(new QName(null, part.getName()),
partWrapper);
+ if (srcPart == null)
+ throw new RuntimeException("Soap body does not contain required part
+"+part.getName());
+
+ odeMessage.setPart(srcPart.getLocalName(), srcPart);
+ }
+ }
+ else
+ {
+ // In doc-literal style, we expect the elements in the body to correspond (in
order)
+ // to the parts defined in the binding.
+ // All the parts should be element-typed, otherwise it is a mess.
+ List<SOAPElement> childElements = new ArrayList<SOAPElement>();
+ final Iterator children = soapBody.getChildElements() ;
+ while(children.hasNext())
+ {
+ final Node node = (Node)children.next() ;
+ if (node instanceof SOAPElement)
+ childElements.add((SOAPElement)node);
+ }
+
+ Iterator<SOAPElement> srcParts = childElements.iterator();
+ for(Part part : parts)
+ {
+ SOAPElement srcPart = srcParts.next();
+ Document doc = DOMUtils.newDocument();
+ Element destPart = doc.createElementNS(null, part.getName());
+ destPart.appendChild(doc.importNode(srcPart, true));
+ odeMessage.setPart(part.getName(), destPart);
+ }
+ }
+ }
+ catch (SOAPException e)
+ {
+ throw new RuntimeException("Failed to extract soap body parts", e);
+ }
+ }
+
+ private static SOAPElement getFirstChildWithName(QName name, SOAPElement parent)
+ {
+ SOAPElement match = null;
+ Iterator iterator = parent.getChildElements(name);
+ while(iterator.hasNext())
+ {
+ match= (SOAPElement)iterator.next();
+ }
+ return match;
+ }
+
+ /*private static Element cloneElement(Element source)
+ {
+ // TODO:
https://jira.jboss.org/jira/browse/RIFTSAW-38
+ // For now create a deep copy (performance hit)
+ try
+ {
+ DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.newDocument();
+ return (Element)doc.importNode(source, true);
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new RuntimeException(e);
+ }
+ } */
+
+ public static <T> T getFirstExtensibilityElement(ElementExtensible parent,
Class<T> cls) {
+ Collection<T> ee = CollectionsX.filter(parent.getExtensibilityElements(),
cls);
+
+ return ee.isEmpty() ? null : ee.iterator().next();
+
+ }
+
+ public static javax.wsdl.extensions.soap.SOAPBody getSOAPBody(ElementExtensible ee) {
+ return getFirstExtensibilityElement(ee, javax.wsdl.extensions.soap.SOAPBody.class);
+ }
+
+ public static List<SOAPHeader> getSOAPHeaders(ElementExtensible eee) {
+ return CollectionsX.filter(new ArrayList<SOAPHeader>(),
(Collection<Object>) eee.getExtensibilityElements(),
+ SOAPHeader.class);
+ }
+
+ public static Fault parseSoapFault(
+ Element odeMessage,
+ SOAPMessage soapMessage,
+ javax.wsdl.Operation operation)
+ {
+ Fault fdef = null;
+ try
+ {
+ SOAPFault flt = soapMessage.getSOAPBody().getFault();
+ Detail detail = flt.getDetail();
+ fdef = inferFault(operation, flt);
+ if(fdef!=null)
+ {
+ Part pdef = (Part)fdef.getMessage().getParts().values().iterator().next();
+ Element partel =
odeMessage.getOwnerDocument().createElementNS(null,pdef.getName());
+ odeMessage.appendChild(partel);
+
+ Element childByName = DOMUtils.findChildByName(detail, pdef.getElementName());
+ if (childByName != null)
+ {
+ partel.appendChild(odeMessage.getOwnerDocument().importNode(childByName,
true));
+ }
+ else
+ {
+ partel.appendChild(odeMessage.getOwnerDocument().importNode(detail,true));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to parse SOAP Fault",e);
+ }
+
+ return fdef;
+ }
+
+ public static Fault parseSoapFault(
+ Element odeMessage,
+ SOAPFault flt,
+ javax.wsdl.Operation operation)
+ {
+ Fault fault=inferFault(operation, flt);
+
+ if(fault!=null)
+ {
+ Detail detail = flt.getDetail();
+ Part pdef = (Part)fault.getMessage().getParts().values().iterator().next();
+ Element partel =
odeMessage.getOwnerDocument().createElementNS(null,pdef.getName());
+ odeMessage.appendChild(partel);
+
+ Element childByName = DOMUtils.findChildByName(detail, pdef.getElementName());
+ if (childByName != null)
+ {
+ partel.appendChild(odeMessage.getOwnerDocument().importNode(childByName,
true));
+ }
+ else
+ {
+ partel.appendChild(odeMessage.getOwnerDocument().importNode(detail,true));
+ }
+ }
+
+ return fault;
+ }
+
+ private static Fault inferFault(Operation operation, SOAPFault flt) {
+ if (!flt.hasDetail())
+ return null;
+ // The detail is a dummy <detail> node containing the interesting fault
element
+ Element element = DOMUtils.getFirstChildElement(flt.getDetail());
+
+ if (element == null) {
+ return(null);
+ }
+
+ QName elName=new QName(element.getNamespaceURI(), element.getLocalName());
+ return WsdlUtils.inferFault(operation, elName);
+ }
+}
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/TemplateWebServiceEndpoint.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/TemplateWebServiceEndpoint.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/TemplateWebServiceEndpoint.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+
+import javax.xml.soap.*;
+import javax.xml.ws.Provider;
+
+
+/**
+ * CXF requires the JAX-WS implementation class to directly implement the
+ * Provider<SOAPMessage>, rather than be derived from a superclass that
+ * implements it. Therefore this 'template' web service endpoint class
+ * has been created, which will be loaded by javassist and renamed to
+ * be the specific endpoint implementation. This is necessary as
+ * javassist does not provide a way to set a interface that uses generics.
+ *
+ * @see org.jboss.soa.si.ws.WebServiceProviderFactory
+ *
+ */
+public class TemplateWebServiceEndpoint extends BaseWebServiceEndpoint implements
Provider<SOAPMessage>
+{
+ // See RIFTSAW-123 for description of issue related to CXF
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLParser.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLParser.java
(rev 0)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLParser.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,223 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+import javax.wsdl.*;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.xml.namespace.QName;
+import java.net.URL;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * WSDL helper class
+ */
+public final class WSDLParser
+{
+
+ private Definition wsdlDefinition;
+ private int dfsDepth = 0;
+
+ public WSDLParser(Definition wsdlDefinition)
+ {
+ this.wsdlDefinition = wsdlDefinition;
+ }
+
+ public void reset()
+ {
+ dfsDepth = 0;
+ }
+
+ public Operation getRPCOperation(QName service, String port, QName payloadName)
+ {
+ reset();
+ Operation result = _getRPCOperation(this.wsdlDefinition, service, port,
payloadName);
+ if (result == null)
+ throw new IllegalArgumentException("Unable to find operation for element
"+payloadName);
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Operation _getRPCOperation(Definition wsdl, QName serviceName, String portName,
QName payloadName)
+ {
+ if(++dfsDepth>50) // easier then retaining references
+ throw new IllegalStateException("Recursive loop detected. DFS depth reached
limit");
+
+ // namespace / java.util.List of imports
+ Collection<List<Import>> imports = wsdl.getImports().values();
+ for(List<Import> importNS : imports)
+ {
+ for(Import wsdlImport : importNS)
+ {
+ Operation result = _getRPCOperation(wsdlImport.getDefinition(), serviceName,
portName, payloadName);
+ if(result!=null)
+ return result;
+ }
+ }
+
+ // resolve the port & operation
+ Service service = wsdl.getService(serviceName);
+ if (service == null)
+ return null; // service might be defined elsewhere
+
+ Port port = service.getPort(portName);
+ if (port == null)
+ throw new IllegalArgumentException("service "+serviceName+" contains
no such port "+portName);
+
+ Binding binding = port.getBinding();
+ PortType portType = binding.getPortType();
+ List<Operation> operations = portType.getOperations();
+ for(Operation op : operations)
+ {
+ if(op.getName().equals(payloadName.getLocalPart()))
+ return op;
+ }
+
+ return null;
+ }
+
+ public Operation getDocLitOperation(QName service, String port, QName payloadName)
+ {
+ reset();
+ Operation result = _getDocLitOperation(this.wsdlDefinition, service, port,
payloadName);
+ if (result == null)
+ throw new IllegalArgumentException("Unable to find operation for element
"+payloadName);
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Operation _getDocLitOperation(Definition wsdl, QName serviceName, String
portName, QName payloadName)
+ {
+ if(++dfsDepth>50) // easier then retaining references
+ throw new IllegalStateException("Recursive loop detected. DFS depth reached
limit");
+
+ // namespace / java.util.List of imports
+ Collection<List<Import>> imports = wsdl.getImports().values();
+ for(List<Import> importNS : imports)
+ {
+ for(Import wsdlImport : importNS)
+ {
+ Operation result = _getDocLitOperation(wsdlImport.getDefinition(), serviceName,
portName, payloadName);
+ if(result!=null)
+ return result;
+ }
+ }
+
+ // resolve the port & operation
+ Service service = wsdl.getService(serviceName);
+ if (service == null)
+ return null; // service might be defined elsewhere
+
+ Port port = service.getPort(portName);
+ if (port == null)
+ throw new IllegalArgumentException("service "+serviceName+" contains
no such port "+portName);
+
+ Binding binding = port.getBinding();
+ PortType portType = binding.getPortType();
+ List<Operation> operations = portType.getOperations();
+ for(Operation op : operations)
+ {
+ Message message = op.getInput().getMessage();
+ Collection<Part> parts = message.getParts().values();
+ for(Part part : parts)
+ {
+ if(part.getElementName().equals(payloadName))
+ return op;
+ }
+ }
+
+ return null;
+ }
+
+ public URL getServiceLocationURL(QName serviceQName, String portName)
+ {
+ reset();
+ return _getServiceLocationURL(this.wsdlDefinition, serviceQName, portName);
+ }
+
+ public URL _getServiceLocationURL(Definition wsdl, QName serviceQName, String
portName)
+ {
+ URL match = null;
+ dfsDepth++;
+
+ if(dfsDepth>50) // easier then retaining references
+ throw new IllegalStateException("Recursive loop detected. DFS depth reached
limit");
+
+ // namespace / java.util.List of imports
+ Map<String, List<Import>> imports = wsdl.getImports();
+ for(String ns : imports.keySet())
+ {
+ List<Import> importNS = imports.get(ns);
+ for(Import wsdlImport : importNS)
+ {
+ URL result = _getServiceLocationURL(wsdlImport.getDefinition(), serviceQName,
portName);
+ if(result!=null)
+ {
+ match = result;
+ break;
+ }
+ }
+
+ if(match!=null) break;
+ }
+
+ if(match!=null) // DFS results
+ return match;
+
+ try
+ {
+ Service service = wsdl.getService(serviceQName);
+ Port port = null;
+ SOAPAddress soapAddress = null;
+
+ // --
+
+ if(service!=null)
+ {
+ port = service.getPort(portName);
+ if(port!=null)
+ {
+ for(Object obj : port.getExtensibilityElements())
+ {
+ if(obj instanceof SOAPAddress)
+ {
+ soapAddress = (SOAPAddress)obj;
+ }
+ }
+
+ }
+ }
+
+ // --
+
+ if(soapAddress!=null)
+ match = new URL(soapAddress.getLocationURI());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to parse " + wsdl, e);
+ }
+
+ return match;
+ }
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLReference.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLReference.java
(rev 0)
+++ trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WSDLReference.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+import javax.wsdl.Definition;
+
+import org.jboss.soa.bpel.runtime.ws.EndpointManager;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Used to pass along both parsed and raw WSDL references.
+ *
+ * @see org.jboss.soa.bpel.runtime.engine.ode.JAXWSBindingContext
+ * @see org.jboss.soa.bpel.runtime.ws.EndpointManager
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ * @author Kurt.Stam <kurt.stam(a)jboss.com>
+ *
+ */
+public final class WSDLReference
+{
+ private Definition definition;
+ private URI wsdlURI;
+
+ public WSDLReference(Definition definition, URI wsdlURI)
+ {
+ this.definition = definition;
+ this.wsdlURI = wsdlURI;
+ }
+
+ public Definition getDefinition()
+ {
+ return definition;
+ }
+
+ public URL getWsdlURL()
+ {
+ try
+ {
+ return wsdlURI.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceDetails.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceDetails.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceDetails.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. 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.jboss.soa.si.ws;
+
+import java.lang.annotation.*;
+
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface WebServiceDetails {
+ String factory();
+}
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceFactory.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceFactory.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceFactory.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. 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.jboss.soa.si.ws;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.soa.bpel.runtime.ws.WSInvocationAdapter;
+import org.jboss.soa.si.ServiceInvoker;
+
+public interface WebServiceFactory {
+
+ public ServiceInvoker getServiceInvoker();
+
+ public WSInvocationAdapter getInvocationAdapter(String operationName,
+ QName serviceName, String portName, SOAPMessageAdapter soapAdapter);
+
+}
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceProviderFactory.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceProviderFactory.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/si/ws/WebServiceProviderFactory.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.soa.si.ws;
+
+import javassist.*;
+import javassist.bytecode.AnnotationsAttribute;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.annotation.Annotation;
+import javassist.bytecode.annotation.EnumMemberValue;
+import javassist.bytecode.annotation.StringMemberValue;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Creates JAX-WS Provider classes using javassist.
+ * These provider classes can then be deployed to JBossWS in memory.<p>
+ * The javassist generated class basically just carries the meta data,
+ * while the actual implementation resides in {@link
org.jboss.soa.si.ws.BaseWebServiceEndpoint}
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class WebServiceProviderFactory
+{
+ private final static String PKG_PREFIX =
WebServiceProviderFactory.class.getPackage().getName()+".generated.";
+
+ public BaseWebServiceEndpoint createProvider(
+ QName service, String port,
+ String endpointId,
+ WSDLReference wsdlRef,
+ ClassLoader loader,
+ java.io.File handlerFile
+ )
+ throws Exception
+ {
+ ClassPool pool = new ClassPool(true);
+ pool.appendClassPath(new LoaderClassPath(loader));
+
+ // Imports
+ pool.importPackage("java.lang");
+ pool.importPackage("javax.xml.ws");
+ pool.importPackage("javax.jws");
+
+ CtClass stringType = pool.get("java.lang.String");
+
+ String implClassName = PKG_PREFIX+"WebServiceEndpoint_"+endpointId;
+ //CtClass impl = pool.makeClass(implClassName);
+
+ // Load an existing class representing the template for a Web Service provider
+ // This was necessary, as javassist does not provide a way to set an implemented
+ // interface that supports generics. Although the super class
(AbstractWebServiceEndpoint)
+ // implements this Provider<SOAPMessage> interface, CXF requires the actual web
service
+ // implementation class to directly define this interface. (RIFTSAW-123)
+ CtClass impl =
pool.get(org.jboss.soa.si.ws.TemplateWebServiceEndpoint.class.getName());
+ impl.setName(implClassName);
+
+ // AbstractWebServiceEndpoint.endpointId property
+ CtField idField = new CtField(stringType, "endpointId", impl);
+ idField.setModifiers(Modifier.PUBLIC);
+ impl.addField(idField, "\""+endpointId+"\"");
+
+ // AbstractWebServiceEndpoint.serviceName property
+ CtField serviceField = new CtField(stringType, "serviceName", impl);
+ serviceField.setModifiers(Modifier.PUBLIC);
+ impl.addField(serviceField,
"\""+service.toString()+"\"");
+
+ // AbstractWebServiceEndpoint.wsdlLocation property
+ CtField wsdlLocationField = new CtField(stringType, "wsdlLocation", impl);
+ wsdlLocationField.setModifiers(Modifier.PUBLIC);
+ impl.addField(wsdlLocationField,
"\""+wsdlRef.getWsdlURL().toExternalForm()+"\"");
+
+ // AbstractWebServiceEndpoint.portName property
+ CtField portNameField = new CtField(stringType, "portName", impl);
+ portNameField.setModifiers(Modifier.PUBLIC);
+ impl.addField(portNameField, "\""+port+"\"");
+
+ // Annotations
+ ClassFile classFile = impl.getClassFile();
+ classFile.setVersionToJava5();
+ ConstPool constantPool = classFile.getConstPool();
+
+ /*
+ @WebServiceProvider(
+ portName="HelloPort",
+ serviceName="HelloService",
+
targetNamespace="http://helloservice.org/wsdl",
+ wsdlLocation="WEB-INF/wsdl/HelloService.wsdl"
+ )
+ @ServiceMode(value=Service.Mode.MESSAGE)
+ */
+ AnnotationsAttribute attr = new
+ AnnotationsAttribute(constantPool, AnnotationsAttribute.visibleTag);
+
+ // --
+ Annotation providerAnnotation = new Annotation(
+ "javax.xml.ws.WebServiceProvider", constantPool);
+
+ providerAnnotation.addMemberValue(
+ "serviceName",
+ new StringMemberValue(service.getLocalPart(), constantPool)
+ );
+ providerAnnotation.addMemberValue(
+ "portName",
+ new StringMemberValue(port, constantPool)
+ );
+ providerAnnotation.addMemberValue(
+ "targetNamespace",
+ new StringMemberValue(service.getNamespaceURI(), constantPool)
+ );
+ providerAnnotation.addMemberValue(
+ "wsdlLocation",
+ new StringMemberValue(wsdlRef.getWsdlURL().toExternalForm(), constantPool)
+ );
+ attr.addAnnotation(providerAnnotation);
+
+ // --
+ Annotation annotation2 = new Annotation("javax.xml.ws.ServiceMode",
+ constantPool);
+ EnumMemberValue enumValue = new EnumMemberValue(constantPool);
+ enumValue.setType("javax.xml.ws.Service$Mode");
+ enumValue.setValue("MESSAGE");
+ annotation2.addMemberValue("value", enumValue);
+
+ attr.addAnnotation(annotation2);
+
+ classFile.addAttribute(attr);
+
+
+ // Check if handler chain should be established
+ if (handlerFile != null) {
+ Annotation handlerChain = new Annotation("javax.jws.HandlerChain",
constantPool);
+
+ handlerChain.addMemberValue("file",
+ new StringMemberValue("/"+handlerFile.getName(), constantPool));
+
+ attr.addAnnotation(handlerChain);
+ }
+
+
+ createStringGetter(impl, stringType, "endpointId",
"getEndpointId");
+ createStringGetter(impl, stringType, "serviceName",
"getServiceName");
+ createStringGetter(impl, stringType, "wsdlLocation",
"getWsdlLocation");
+ createStringGetter(impl, stringType, "portName", "getPortName");
+
+ // ------------
+
+ // freeze
+ impl.stopPruning(false);
+ impl.toClass(loader);
+ JavaUtils.clearBlacklists(loader);
+
+ // test it
+ Class clazz = loader.loadClass(implClassName);
+
+ BaseWebServiceEndpoint obj = (BaseWebServiceEndpoint)clazz.newInstance();
+
+ return obj;
+ }
+
+ private void createStringGetter(CtClass impl, CtClass stringType, String property,
String methodName)
+ throws Exception
+ {
+ CtMethod method = new CtMethod(
+ stringType, methodName,
+ new CtClass[]{},
+ impl
+ );
+
+ // Method body
+ StringBuffer body = new StringBuffer();
+ body.append("{");
+ body.append("return this."+property+";");
+ body.append("}");
+
+ method.setBody(body.toString());
+
+ impl.addMethod(method);
+
+ }
+}
Modified: trunk/runtime/engine/src/test/java/riftsaw124/Riftsaw124TestCase.java
===================================================================
--- trunk/runtime/engine/src/test/java/riftsaw124/Riftsaw124TestCase.java 2010-11-15
11:59:30 UTC (rev 1106)
+++ trunk/runtime/engine/src/test/java/riftsaw124/Riftsaw124TestCase.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -22,8 +22,9 @@
package riftsaw124;
import junit.framework.TestCase;
-import org.jboss.soa.bpel.runtime.ws.WSDLParser;
+import org.jboss.soa.si.ws.WSDLParser;
+
import javax.wsdl.Definition;
import javax.wsdl.Operation;
import javax.wsdl.factory.WSDLFactory;
Modified: trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java
===================================================================
--- trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java 2010-11-15
11:59:30 UTC (rev 1106)
+++ trunk/runtime/engine/src/test/java/riftsaw277/Riftsaw277TestCase.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -23,7 +23,7 @@
import javax.xml.soap.SOAPMessage;
-import org.jboss.soa.bpel.runtime.ws.SOAPMessageAdapter;
+import org.jboss.soa.si.ws.SOAPMessageAdapter;
import junit.framework.TestCase;
Modified:
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/internal/soa/esb/actions/bpel/ESBInvocationAdapter.java
===================================================================
---
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/internal/soa/esb/actions/bpel/ESBInvocationAdapter.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/jbossesb-bpel/src/main/java/org/jboss/internal/soa/esb/actions/bpel/ESBInvocationAdapter.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -23,7 +23,7 @@
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
-import org.jboss.soa.bpel.runtime.engine.InvocationAdapter;
+import org.jboss.soa.si.InvocationAdapter;
import org.w3c.dom.Element;
import javax.xml.namespace.QName;
Modified:
trunk/runtime/jbossesb-bpel/src/test/java/org/jboss/soa/esb/actions/bpel/TestBPELEngine.java
===================================================================
---
trunk/runtime/jbossesb-bpel/src/test/java/org/jboss/soa/esb/actions/bpel/TestBPELEngine.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/jbossesb-bpel/src/test/java/org/jboss/soa/esb/actions/bpel/TestBPELEngine.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -20,7 +20,7 @@
import org.jboss.internal.soa.esb.actions.bpel.ESBInvocationAdapter;
import org.jboss.soa.bpel.runtime.engine.BPELEngine;
-import org.jboss.soa.bpel.runtime.engine.InvocationAdapter;
+import org.jboss.soa.si.InvocationAdapter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.namespace.QName;
Modified:
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java
===================================================================
---
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java 2010-11-15
11:59:30 UTC (rev 1106)
+++
trunk/runtime/uddi/src/main/java/org/jboss/soa/bpel/uddi/UDDIRegistrationImpl.java 2010-11-16
13:36:29 UTC (rev 1107)
@@ -46,8 +46,8 @@
import org.apache.juddi.v3.client.transport.TransportException;
import org.jboss.soa.bpel.runtime.engine.ode.UDDIRegistration;
import org.jboss.soa.bpel.runtime.integration.ServerConfigFactory;
-import org.jboss.soa.bpel.runtime.ws.WSDLReference;
import org.jboss.soa.bpel.runtime.ws.WebServiceClient;
+import org.jboss.soa.si.ws.WSDLReference;
import org.uddi.api_v3.AccessPoint;
import org.uddi.api_v3.BindingTemplate;
import org.uddi.api_v3.BindingTemplates;