Commit in servicemix/components/jaxws/src on MAIN
main/java/org/servicemix/components/jaxws/ServiceBinder.java+85added 1.1
                                         /JBIProvider.java+89added 1.1
                                         /JAXWSBinding.java+37-121.1 -> 1.2
test/resources/org/servicemix/components/jaxws/AddNumbers.wsdl+1-11.1 -> 1.2
                                              /example.xml-11.1 -> 1.2
test/java/org/servicemix/components/jaxws/AddNumbersImpl.java+32added 1.1
                                         /JAXWSTest.java+1-11.1 -> 1.2
+245-15
3 added + 4 modified, total 7 files
Updated the JAX-WS binding to work with the current version of JAX-WS (slightly patched due to a bug in the RI). So far we can perform client side invocations from JBI into JAX-WS as well as using JBI as a provider of a JAX-RPC service.

We still need a neater way of hosting a JAX-WS service in ServiceMix though; which requires patches to JAX-WS RI

servicemix/components/jaxws/src/main/java/org/servicemix/components/jaxws
ServiceBinder.java added at 1.1
diff -N ServiceBinder.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ServiceBinder.java	1 Sep 2005 18:48:39 -0000	1.1
@@ -0,0 +1,85 @@
+/**
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ * 
+ **/
+package org.servicemix.components.jaxws;
+
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.EndpointFactory;
+
+import java.net.URI;
+
+/**
+ * Binds a service implementation POJO to JAX-WS
+ *
+ * @version $Revision$
+ */
+public class ServiceBinder {
+
+    private EndpointFactory endpointFactory;
+    private Endpoint endpoint;
+    private URI uri;
+    private Object implementation;
+
+    public EndpointFactory getEndpointFactory() {
+        if (endpointFactory == null) {
+            endpointFactory = EndpointFactory.newInstance();
+        }
+        return endpointFactory;
+    }
+
+    public void setEndpointFactory(EndpointFactory endpointFactory) {
+        this.endpointFactory = endpointFactory;
+    }
+
+    public Endpoint getEndpoint() {
+        if (endpoint == null) {
+            endpoint = createEndpoint();
+        }
+        return endpoint;
+    }
+
+    public void setEndpoint(Endpoint endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public Object getImplementation() {
+        return implementation;
+    }
+
+    public void setImplementation(Object implementation) {
+        this.implementation = implementation;
+    }
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public void setUri(URI uri) {
+        this.uri = uri;
+    }
+
+    protected Endpoint createEndpoint() {
+        if (uri == null) {
+            throw new IllegalArgumentException("You must configure the 'uri' property");
+        }
+        if (implementation == null) {
+            throw new IllegalArgumentException("You must configure the 'implementation' property");
+        }
+        return getEndpointFactory().createEndpoint(uri, implementation);
+    }
+    
+}

servicemix/components/jaxws/src/main/java/org/servicemix/components/jaxws
JBIProvider.java added at 1.1
diff -N JBIProvider.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ JBIProvider.java	1 Sep 2005 18:48:39 -0000	1.1
@@ -0,0 +1,89 @@
+/**
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ * 
+ **/
+package org.servicemix.components.jaxws;
+
+import org.servicemix.client.ServiceMixClient;
+
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.Source;
+import javax.xml.ws.Provider;
+import javax.xml.ws.WebServiceException;
+
+import java.util.Map;
+
+/**
+ * A JAX-WS [EMAIL PROTECTED] Provider} which implements the service by dispatching into
+ * the JBI container.
+ * 
+ * @version $Revision$
+ */
+public class JBIProvider implements Provider<Source> {
+
+    private ServiceMixClient client;
+    private Map<String, Object> exchangeProperties;
+    private Map<String, Object> messageProperties;
+
+    public JBIProvider(ServiceMixClient client) {
+        this.client = client;
+    }
+
+    public Map<String, Object> getExchangeProperties() {
+        return exchangeProperties;
+    }
+
+    public void setExchangeProperties(Map<String, Object> exchangeProperties) {
+        this.exchangeProperties = exchangeProperties;
+    }
+
+    public Map<String, Object> getMessageProperties() {
+        return messageProperties;
+    }
+
+    public void setMessageProperties(Map<String, Object> messageProperties) {
+        this.messageProperties = messageProperties;
+    }
+
+    public Source invoke(Source request) {
+        try {
+            InOut exchange = client.createInOutExchange();
+            NormalizedMessage in = exchange.getInMessage();
+            in.setContent(request);
+            configureInMessage(exchange, in);
+            client.send(exchange);
+            return exchange.getOutMessage().getContent();
+        }
+        catch (MessagingException e) {
+            throw new WebServiceException(e);
+        }
+    }
+
+    protected void configureInMessage(InOut exchange, NormalizedMessage in) {
+        if (messageProperties != null) {
+            for (Map.Entry<String, Object> entry : messageProperties.entrySet()) {
+                in.setProperty(entry.getKey(), entry.getValue());
+            }
+        }
+        if (exchangeProperties != null) {
+            for (Map.Entry<String, Object> entry : exchangeProperties.entrySet()) {
+                exchange.setProperty(entry.getKey(), entry.getValue());
+            }
+        }
+    }
+}

servicemix/components/jaxws/src/main/java/org/servicemix/components/jaxws
JAXWSBinding.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- JAXWSBinding.java	31 Aug 2005 15:43:54 -0000	1.1
+++ JAXWSBinding.java	1 Sep 2005 18:48:39 -0000	1.2
@@ -1,6 +1,6 @@
 /**
  * 
- * Copyright 2005 Protique Ltd
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
  * 
  * Licensed under the Apache License, Version 2.0 (the "License"); 
  * you may not use this file except in compliance with the License. 
@@ -32,10 +32,13 @@
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service;
 import javax.xml.ws.ServiceFactory;
+import javax.xml.ws.WebServiceException;
 import javax.xml.ws.Service.Mode;
 
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.Iterator;
 
 /**
  * Converts an inbound JBI message into a <a
@@ -55,7 +58,7 @@
     private boolean defaultInOut = true;
     private Resource wsdlResource;
 
-    public Dispatch<Source> getDispatch() throws IOException {
+    public Dispatch<Source> getDispatch() throws IOException, URISyntaxException, MessagingException {
         if (dispatch == null) {
             dispatch = createDispatch();
         }
@@ -147,6 +150,9 @@
         catch (IOException e) {
             throw new JBIException("Failed to create Dispatch: " + e, e);
         }
+        catch (URISyntaxException e) {
+            throw new JBIException("Failed to create Dispatch: " + e, e);
+        }
     }
 
     protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
@@ -154,13 +160,18 @@
 
         Source content = getInMessage(exchange).getContent();
 
-        if (isInOutRequest(exchange, in, out)) {
-            copyProperties(exchange, in, out);
-            Source answer = dispatch.invoke(content);
-            out.setContent(answer);
+        try {
+            if (isInOutRequest(exchange, in, out)) {
+                copyProperties(exchange, in, out);
+                Source answer = dispatch.invoke(content);
+                out.setContent(answer);
+            }
+            else {
+                dispatch.invokeOneWay(content);
+            }
         }
-        else {
-            dispatch.invokeOneWay(content);
+        catch (WebServiceException e) {
+            throw new MessagingException(e);
         }
         return true;
     }
@@ -173,8 +184,24 @@
         return isDefaultInOut();
     }
 
-    protected Dispatch<Source> createDispatch() throws IOException {
-        return getJaxService().createDispatch(getInterfaceName(), Source.class, getMode());
+    protected Dispatch<Source> createDispatch() throws IOException, URISyntaxException, MessagingException {
+        Service webService = getJaxService();
+        QName interfaceName = getInterfaceName();
+        if (interfaceName == null) {
+            interfaceName = findInterfaceName(webService);
+        }
+        /*
+        webService.addPort(interfaceName, getPortBindingId(), getEndpointAddress());
+        */
+        return webService.createDispatch(interfaceName, Source.class, getMode());
+    }
+
+    protected QName findInterfaceName(Service webService) throws MessagingException {
+        Iterator<QName> iter = webService.getPorts();
+        while (iter.hasNext()) {
+            return iter.next();
+        }
+        throw new MessagingException("No interfaceName property is specified and the Service implementation has no ports available!");
     }
 
     protected Service createJaxService() throws IOException {
@@ -194,6 +221,4 @@
         }
         return null;
     }
-
-
 }

servicemix/components/jaxws/src/test/resources/org/servicemix/components/jaxws
AddNumbers.wsdl 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- AddNumbers.wsdl	31 Aug 2005 15:47:38 -0000	1.1
+++ AddNumbers.wsdl	1 Sep 2005 18:48:39 -0000	1.2
@@ -55,7 +55,7 @@
     </binding>
     <service name="AddNumbersService">
         <port name="AddNumbersPort" binding="tns:AddNumbersBinding">
-            <soap:address location="REPLACE_WITH_ACTUAL_URL" />
+            <soap:address location="http://localhost:8080/addnumbers" />
         </port>
     </service>
 </definitions>

servicemix/components/jaxws/src/test/resources/org/servicemix/components/jaxws
example.xml 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- example.xml	31 Aug 2005 15:47:38 -0000	1.1
+++ example.xml	1 Sep 2005 18:48:39 -0000	1.2
@@ -5,7 +5,6 @@
     <components>
       <!-- START SNIPPET: jaxws -->
       <component id="addNumbersService" service="foo:AddNumbersService" class="org.servicemix.components.jaxws.JAXWSBinding">
-        <property name="interfaceName"><qname>foo:AddNumbersPort</qname></property>
         <property name="wsdlResource" value="classpath:org/servicemix/components/jaxws/AddNumbers.wsdl"/>
        </component>
       <!-- END SNIPPET: jaxws -->

servicemix/components/jaxws/src/test/java/org/servicemix/components/jaxws
AddNumbersImpl.java added at 1.1
diff -N AddNumbersImpl.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ AddNumbersImpl.java	1 Sep 2005 18:48:39 -0000	1.1
@@ -0,0 +1,32 @@
+/**
+ * 
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ * 
+ **/
+package org.servicemix.components.jaxws;
+
+import javax.jws.WebService;
+
+/**
+ * A dummy service implementation
+ *
+ * @version $Revision$
+ */
[EMAIL PROTECTED]
+public class AddNumbersImpl {
+    public int addNumbers (int number1, int number2) {
+        return number1 + number2;
+    }
+}
\ No newline at end of file

servicemix/components/jaxws/src/test/java/org/servicemix/components/jaxws
JAXWSTest.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- JAXWSTest.java	31 Aug 2005 15:43:54 -0000	1.1
+++ JAXWSTest.java	1 Sep 2005 18:48:39 -0000	1.2
@@ -31,7 +31,7 @@
 
     protected String quote = "SUNW";
 
-    public void testCurrencyQuotes() throws Exception {
+    public void testJAXWSService() throws Exception {
         QName serviceName = new QName("http://duke.org", "AddNumbersService");
         String file = "request.xml";
 
CVSspam 0.2.8

Reply via email to