You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/08/17 21:54:07 UTC
svn commit: r1374414 - in /cxf/trunk/services/ws-discovery/ws-discovery-api:
./ src/main/java/org/apache/cxf/ws/discovery/
src/main/resources/org/apache/cxf/ws/discovery/wsdl/
src/test/java/org/apache/cxf/ws/discovery/
Author: dkulp
Date: Fri Aug 17 19:54:07 2012
New Revision: 1374414
URL: http://svn.apache.org/viewvc?rev=1374414&view=rev
Log:
Start stubbing in a WSDiscovery service that will respond to the probes
Added:
cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java
Modified:
cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml
cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/resources/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml?rev=1374414&r1=1374413&r2=1374414&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml Fri Aug 17 19:54:07 2012
@@ -76,11 +76,11 @@
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl</wsdl>
- <asyncMethods></asyncMethods>
<extraargs>
<extraArg>-p</extraArg>
<extraArg>org.apache.cxf.ws.discovery.wsdl</extraArg>
</extraargs>
+ <wsdlLocation>classpath:/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java?rev=1374414&r1=1374413&r2=1374414&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java Fri Aug 17 19:54:07 2012
@@ -198,16 +198,7 @@ public class WSDiscoveryClient implement
bt.setEndpointReference(hello.getEndpointReference());
unregister(bt);
}
- public void unregister(EndpointReference ert) {
- ByeType bt = new ByeType();
- bt.setScopes(new ScopesType());
- EndpointReferenceType ref = ProviderImpl.convertToInternal(ert);
- proccessEndpointReference(ref, bt.getScopes(),
- bt.getTypes(),
- bt.getXAddrs());
- bt.setEndpointReference(generateW3CEndpointReference());
- unregister(bt);
- }
+
public ProbeMatchesType probe(ProbeType params) {
return probe(params, 1000);
Added: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java?rev=1374414&view=auto
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java (added)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java Fri Aug 17 19:54:07 2012
@@ -0,0 +1,118 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.ws.discovery;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.util.JAXBSource;
+import javax.xml.transform.Source;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Provider;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.Addressing;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.jaxb.JAXBContextCache;
+import org.apache.cxf.ws.discovery.wsdl.HelloType;
+import org.apache.cxf.ws.discovery.wsdl.ObjectFactory;
+import org.apache.cxf.ws.discovery.wsdl.ProbeMatchType;
+import org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType;
+import org.apache.cxf.ws.discovery.wsdl.ProbeType;
+
+public class WSDiscoveryService {
+ Bus bus;
+ Endpoint udpEndpoint;
+ WSDiscoveryClient client;
+ List<HelloType> registered = new ArrayList<HelloType>();
+ ObjectFactory factory = new ObjectFactory();
+
+ public WSDiscoveryService(Bus b) {
+ bus = b;
+ client = new WSDiscoveryClient();
+ }
+
+ public HelloType register(EndpointReference ref) {
+ HelloType ht = client.register(ref);
+ registered.add(ht);
+ return ht;
+ }
+ public void unregister(HelloType ht) {
+ registered.remove(ht);
+ client.unregister(ht);
+ }
+
+
+
+ public void startup() {
+ udpEndpoint = Endpoint.create(new WSDiscoveryProvider());
+ udpEndpoint.publish("soap.udp://239.255.255.250:3702");
+ }
+
+ @WebServiceProvider(wsdlLocation = "classpath:/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl",
+ targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01",
+ serviceName = "Discovery",
+ portName = "DiscoveryUDP")
+ @XmlSeeAlso(ObjectFactory.class)
+ @Addressing(required = true)
+ class WSDiscoveryProvider implements Provider<Source> {
+
+ JAXBContext context;
+ public WSDiscoveryProvider() {
+ try {
+ context = JAXBContextCache.getCachedContextAndSchemas(ObjectFactory.class).getContext();
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Source invoke(Source request) {
+ try {
+ Object obj = context.createUnmarshaller().unmarshal(request);
+ if (obj instanceof JAXBElement) {
+ obj = ((JAXBElement)obj).getValue();
+ }
+ if (obj instanceof ProbeType) {
+ ProbeMatchesType pmt = new ProbeMatchesType();
+ for (HelloType ht : registered) {
+ ProbeMatchType m = new ProbeMatchType();
+ m.setEndpointReference(ht.getEndpointReference());
+ m.setScopes(ht.getScopes());
+ m.setMetadataVersion(ht.getMetadataVersion());
+ m.getTypes().addAll(ht.getTypes());
+ m.getXAddrs().addAll(ht.getXAddrs());
+ pmt.getProbeMatch().add(m);
+ }
+ return new JAXBSource(context, factory.createProbeMatches(pmt));
+ }
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+ }
+
+}
Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/resources/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/resources/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl?rev=1374414&r1=1374413&r2=1374414&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/resources/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/resources/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl Fri Aug 17 19:54:07 2012
@@ -23,7 +23,8 @@ The name "OASIS" is trademarks of OASIS,
xmlns:tns="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:xs="http://www.w3.org/2001/XMLSchema" >
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/">
<wsdl:types>
<xs:schema>
<xs:import
@@ -133,4 +134,52 @@ The name "OASIS" is trademarks of OASIS,
/>
</wsdl:operation>
</wsdl:portType>
+ <wsdl:binding name="DiscoveryProxy" type="tns:DiscoveryProxy">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="HelloOp">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/HelloOp" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="ByeOp">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ByeOp" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ </wsdl:operation>
+ <wsdl:operation name="ProbeOp">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeOp" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="ResolveOp">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ResolveOp" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+
+ <wsdl:service name="Discovery">
+ <wsdl:port name="DiscoveryUDP" binding="tns:DiscoveryProxy">
+ <soap:address location="soap.udp://:3702"/>
+ </wsdl:port>
+ <wsdl:port name="DiscoveryProxy" binding="tns:DiscoveryProxy">
+ <soap:address location="http://0.0.0.0:3702/DiscoveryProxy"/>
+ </wsdl:port>
+ </wsdl:service>
</wsdl:definitions>
Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java?rev=1374414&r1=1374413&r2=1374414&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java Fri Aug 17 19:54:07 2012
@@ -42,11 +42,15 @@ public final class WSDiscoveryClientTest
public static void main(String[] arg) throws Exception {
try {
Endpoint ep = Endpoint.publish("http://localhost:51919/Foo/Snarf", new FooImpl());
+ WSDiscoveryService service = new WSDiscoveryService(null);
+ service.startup();
+
+
WSDiscoveryClient c = new WSDiscoveryClient();
- HelloType h = c.register(ep.getEndpointReference());
+ HelloType h = service.register(ep.getEndpointReference());
+
System.out.println("1");
- Thread.sleep(1000);
ProbeMatchesType pmts = c.probe(new ProbeType());
System.out.println("2");
if (pmts != null) {
@@ -58,6 +62,7 @@ public final class WSDiscoveryClientTest
}
pmts = c.probe(new ProbeType());
System.out.println("3");
+
if (pmts != null) {
for (ProbeMatchType pmt : pmts.getProbeMatch()) {
System.out.println("Found " + pmt.getEndpointReference());
@@ -65,13 +70,13 @@ public final class WSDiscoveryClientTest
System.out.println(pmt.getXAddrs());
}
}
-
- c.unregister(h);
+ service.unregister(h);
System.out.println("4");
c.close();
System.exit(0);
} catch (Throwable t) {
+ t.printStackTrace();
System.exit(1);
}
}