Author: heiko.braun(a)jboss.com
Date: 2009-11-25 06:54:05 -0500 (Wed, 25 Nov 2009)
New Revision: 326
Added:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/Runner.java
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLParser.java
Removed:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLQuery.java
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/ws/AbstractWebServiceEndpoint.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/SOAPMessageAdapter.java
trunk/samples/quickstart/hello_world/bpel/HelloWorld.wsdl
Log:
Fix RIFTSAW-118: Wrong op name on doclit requests
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 2009-11-25
11:00:37 UTC (rev 325)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/JAXWSBindingContext.java 2009-11-25
11:54:05 UTC (rev 326)
@@ -21,10 +21,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.iapi.*;
import org.jboss.soa.bpel.runtime.engine.PartnerChannel;
-import org.jboss.soa.bpel.runtime.ws.EndpointManager;
-import org.jboss.soa.bpel.runtime.ws.EndpointMetaData;
-import org.jboss.soa.bpel.runtime.ws.WSDLQuery;
-import org.jboss.soa.bpel.runtime.ws.WSDLReference;
+import org.jboss.soa.bpel.runtime.ws.*;
import javax.wsdl.Definition;
import javax.wsdl.PortType;
@@ -114,7 +111,7 @@
{
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
Definition def = wsdlReader.readWSDL(f.toURL().toExternalForm());
- URL url = new WSDLQuery(def).query(myRoleEndpoint.serviceName,
myRoleEndpoint.portName);
+ URL url = WSDLParser.getServiceLocationURL(def, myRoleEndpoint.serviceName,
myRoleEndpoint.portName);
if(url!=null)
{
targetWsdlFile = f;
Modified:
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2009-11-25
11:00:37 UTC (rev 325)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/AbstractWebServiceEndpoint.java 2009-11-25
11:54:05 UTC (rev 326)
@@ -32,6 +32,7 @@
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;
@@ -53,6 +54,7 @@
private SOAPMessageAdapter soapAdapter;
private QName serviceQName;
+ private Definition wsdlDefinition;
private boolean isInitialized;
@@ -63,7 +65,7 @@
try
{
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
- Definition wsdlDefinition = wsdlReader.readWSDL(getWsdlLocation());
+ this.wsdlDefinition = wsdlReader.readWSDL(getWsdlLocation());
this.serviceQName = QName.valueOf(getServiceName());
this.soapAdapter = new SOAPMessageAdapter(wsdlDefinition, serviceQName,
getPortName());
}
@@ -90,8 +92,10 @@
log.debug( "ODE inbound message: \n" +DOMWriter.printNode(soapEnvelope,
true) );
// Create invocation context
+ final String operationName = resolveOperationName(messageElement);
+
WSInvocationAdapter invocationContext = new WSInvocationAdapter(
- messageElement.getLocalName(),
+ operationName,
serviceQName,
soapAdapter
);
@@ -116,6 +120,23 @@
}
}
+ public String resolveOperationName(Element payload)
+ {
+ if(soapAdapter.isRPC())
+ {
+ return payload.getLocalName();
+ }
+ else
+ {
+ QName elementName = new QName(payload.getNamespaceURI(), payload.getLocalName());
+ Operation op = WSDLParser.getDocLitOperation(
+ this.serviceQName, getPortName(), elementName , wsdlDefinition
+ );
+
+ return op.getName();
+ }
+ }
+
public static Element getMessagePayload(SOAPEnvelope soapEnvelope)
throws SOAPException
{
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 2009-11-25
11:00:37 UTC (rev 325)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2009-11-25
11:54:05 UTC (rev 326)
@@ -108,8 +108,7 @@
ClassLoaderFactory clf = new DelegatingClassLoaderFactory(classLoader);
// WebMetaData
- WSDLQuery addressQuery = new WSDLQuery(wsdlRef.getDefinition());
- URL serviceUrl = addressQuery.query(metaData.getServiceName(),
metaData.getPortName());
+ URL serviceUrl = WSDLParser.getServiceLocationURL(wsdlRef.getDefinition(),
metaData.getServiceName(), metaData.getPortName());
String[] webContext = deriveWebContextFromServiceUrl(serviceUrl);
WebMetaDataFactory wmdFactory = new WebMetaDataFactory(
Added: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/Runner.java
===================================================================
--- trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/Runner.java
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/Runner.java 2009-11-25
11:54:05 UTC (rev 326)
@@ -0,0 +1,56 @@
+/*
+ * 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 javax.wsdl.Operation;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+public class Runner
+{
+ static QName service;
+ static String port;
+
+ public static void main(String[] args) throws Exception
+ {
+ // HelloWorldProcessRequest
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ Definition wsdlDefinition =
wsdlReader.readWSDL("file:///Users/hbraun/Downloads/HelloWorldProcessArtifacts.wsdl");
+
+ service = new
QName("http://jboss.com/bpel/helloWorld",
"HelloWorldProcessService");
+ port = "HelloWorldProcessServicePort";
+
+ SOAPMessageAdapter soapAdapter =new SOAPMessageAdapter(wsdlDefinition, service,
port);
+
+ System.out.println("RPC ? "+soapAdapter.isRPC());
+
+ Operation op = WSDLParser.getDocLitOperation(
+ service, port, new
QName("http://jboss.com/bpel/helloWorld",
"HelloWorldProcessRequest"), wsdlDefinition
+ );
+
+ System.out.println("operation: "+op.getName());
+ }
+
+}
Modified:
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 2009-11-25
11:00:37 UTC (rev 325)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/SOAPMessageAdapter.java 2009-11-25
11:54:05 UTC (rev 326)
@@ -133,6 +133,11 @@
}
+ public boolean isRPC()
+ {
+ return isRPC;
+ }
+
public void createSoapResponse(SOAPMessage soapMessage, Message odeResponseMessage,
Operation wsdlOperation)
{
@@ -341,9 +346,19 @@
}
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.
- Iterator<SOAPElement> srcParts = soapBody.getChildElements();
+ // 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();
Added: 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
(rev 0)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLParser.java 2009-11-25
11:54:05 UTC (rev 326)
@@ -0,0 +1,123 @@
+/*
+ * 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.List;
+import java.util.Map;
+
+/**
+ * WSDL helper class
+ */
+public class WSDLParser
+{
+ public static Operation getDocLitOperation(QName service, String port, QName
payloadName, Definition wsdl)
+ {
+ // resolve wsdl:message
+ Map<QName, Message> messages = wsdl.getMessages();
+ QName relatedMessage = null;
+ for(QName qname : messages.keySet())
+ {
+ Message candidate = messages.get(qname);
+ Map<String, Part> parts = candidate.getParts();
+ for(String s : parts.keySet())
+ {
+ Part p = parts.get(s);
+ if(p.getElementName().equals(payloadName))
+ {
+ relatedMessage = qname;
+ break;
+ }
+ }
+ }
+
+ if(null==relatedMessage)
+ throw new IllegalArgumentException("Unable to find WSDL Message for element
"+payloadName);
+
+ // resolve the port & operation
+ Operation relatedOperation = null;
+
+ Service s = wsdl.getService(service);
+ Port p = s.getPort(port);
+ Binding b = p.getBinding();
+
+ PortType portType = b.getPortType();
+ List<Operation> operations = portType.getOperations();
+ for(Operation op : operations)
+ {
+ if(op.getInput().getMessage().getQName().equals(relatedMessage))
+ {
+ relatedOperation = op;
+ break;
+ }
+ }
+
+ if(null==relatedOperation)
+ throw new IllegalArgumentException("Unable to find WSDL Operation for Message
"+relatedMessage);
+
+ return relatedOperation;
+ }
+
+ public static URL getServiceLocationURL(Definition wsdl, QName serviceQName, String
portName)
+ {
+ URL url = null;
+
+ 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)
+ url = new URL(soapAddress.getLocationURI());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to parse " + wsdl, e);
+ }
+
+ return url;
+ }
+}
Deleted: trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLQuery.java
===================================================================
---
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLQuery.java 2009-11-25
11:00:37 UTC (rev 325)
+++
trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WSDLQuery.java 2009-11-25
11:54:05 UTC (rev 326)
@@ -1,85 +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 javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.xml.namespace.QName;
-import java.net.URL;
-
-/**
- * Queries a service URL soap address.
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class WSDLQuery
-{
- private Definition definition;
-
- public WSDLQuery(Definition wsdl)
- {
- this.definition = wsdl;
- }
-
- public URL query(QName serviceQName, String portName)
- {
- URL url = null;
-
- try
- {
- Service service = definition.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)
- url = new URL(soapAddress.getLocationURI());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to parse " + definition, e);
- }
-
- return url;
- }
-}
Modified: trunk/samples/quickstart/hello_world/bpel/HelloWorld.wsdl
===================================================================
--- trunk/samples/quickstart/hello_world/bpel/HelloWorld.wsdl 2009-11-25 11:00:37 UTC (rev
325)
+++ trunk/samples/quickstart/hello_world/bpel/HelloWorld.wsdl 2009-11-25 11:54:05 UTC (rev
326)
@@ -17,51 +17,51 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-<wsdl:definitions
-
targetNamespace="http://www.jboss.org/bpel/examples/wsdl"
-
xmlns="http://schemas.xmlsoap.org/wsdl/"
-
xmlns:tns="http://www.jboss.org/bpel/examples/wsdl"
-
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
-
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
-
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
-
+<wsdl:definitions
+
targetNamespace="http://www.jboss.org/bpel/examples/wsdl"
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:tns="http://www.jboss.org/bpel/examples/wsdl"
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+
<wsdl:message name="HelloMessage">
<wsdl:part name="TestPart" type="xsd:string"/>
</wsdl:message>
-
+
<wsdl:portType name="HelloPortType">
<wsdl:operation name="hello">
<wsdl:input message="tns:HelloMessage"
name="TestIn"/>
<wsdl:output message="tns:HelloMessage"
name="TestOut"/>
- </wsdl:operation>
+ </wsdl:operation>
</wsdl:portType>
-
- <wsdl:binding name="HelloSoapBinding"
type="tns:HelloPortType">
+
+ <wsdl:binding name="HelloSoapBinding"
type="tns:HelloPortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="hello">
<soap:operation soapAction="" style="rpc"/>
<wsdl:input>
<soap:body
-
namespace="http://www.jboss.org/bpel/examples/wsdl"
- use="literal"/>
+
namespace="http://www.jboss.org/bpel/examples/wsdl"
+ use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body
-
namespace="http://www.jboss.org/bpel/examples/wsdl"
- use="literal"/>
+
namespace="http://www.jboss.org/bpel/examples/wsdl"
+ use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="HelloService">
- <wsdl:port name="HelloPort"
binding="tns:HelloSoapBinding">
- <soap:address
location="http://localhost:8080/Quickstart_bpel_hello_worldWS"/>
- </wsdl:port>
- </wsdl:service>
+ <wsdl:service name="HelloService">
+ <wsdl:port name="HelloPort"
binding="tns:HelloSoapBinding">
+ <soap:address
location="http://localhost:8080/Quickstart_bpel_hello_worldWS"/>
+ </wsdl:port>
+ </wsdl:service>
- <plnk:partnerLinkType name="HelloPartnerLinkType">
- <plnk:role name="me" portType="tns:HelloPortType"/>
- <plnk:role name="you" portType="tns:HelloPortType"/>
- </plnk:partnerLinkType>
+ <plnk:partnerLinkType name="HelloPartnerLinkType">
+ <plnk:role name="me" portType="tns:HelloPortType"/>
+ <plnk:role name="you" portType="tns:HelloPortType"/>
+ </plnk:partnerLinkType>
</wsdl:definitions>