Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Schneider
committed
Aug 7, 2012
1 parent
3077256
commit 84f535b
Showing
19 changed files
with
699 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
install -s mvn:org.apache.cxf.samples/docservice/1.0.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!-- Copyright (C) 2010 Talend Inc. - www.talend.com --> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.apache.cxf.samples</groupId> | ||
<artifactId>docservice</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>bundle</packaging> | ||
|
||
<properties> | ||
<cxf.version>2.6.1</cxf.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-frontend-jaxrs</artifactId> | ||
<version>${cxf.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-frontend-jaxws</artifactId> | ||
<version>${cxf.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
|
||
</instructions> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
|
||
|
24 changes: 24 additions & 0 deletions
24
examples/docservice/src/main/java/docservice/client/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package docservice.client; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
|
||
import javax.activation.DataHandler; | ||
|
||
import org.apache.cxf.jaxrs.client.WebClient; | ||
|
||
public class Client { | ||
|
||
/** | ||
* @param args | ||
* @throws IOException | ||
* @throws FileNotFoundException | ||
*/ | ||
public static void main(String[] args) throws FileNotFoundException, IOException { | ||
WebClient wc = WebClient.create("http://localhost:8040/services/docservice/doc/out.pdf"); | ||
DataHandler dh = wc.get(DataHandler.class); | ||
dh.writeTo(new FileOutputStream("out2.pdf")); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
examples/docservice/src/main/java/docservice/common/DocService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (C) 2010 Talend Inc. - www.talend.com | ||
*/ | ||
package docservice.common; | ||
|
||
import javax.activation.DataHandler; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
|
||
@Path("/doc") | ||
public interface DocService { | ||
|
||
@Path("/{id}") | ||
@GET | ||
@Produces("application/xml") | ||
public DataHandler read(@PathParam("id") String id); | ||
|
||
@Path("/{id}") | ||
@PUT | ||
@Consumes("application/xml") | ||
public void write(@PathParam("id") String id, DataHandler content); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
examples/docservice/src/main/java/docservice/service/DocServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (C) 2010 Talend Inc. - www.talend.com | ||
*/ | ||
package docservice.service; | ||
|
||
import java.io.FileOutputStream; | ||
|
||
import javax.activation.DataHandler; | ||
import javax.activation.FileDataSource; | ||
|
||
import docservice.common.DocService; | ||
|
||
public class DocServiceImpl implements DocService { | ||
|
||
@Override | ||
public DataHandler read(String id) { | ||
FileDataSource fds = new FileDataSource("target/" + id); | ||
return new DataHandler(fds); | ||
} | ||
|
||
@Override | ||
public void write(String id, DataHandler content) { | ||
try { | ||
FileOutputStream fos = new FileOutputStream("target/" + id); | ||
content.writeTo(fos); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
examples/docservice/src/main/resources/OSGI-INF/blueprint/service.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!-- | ||
~ /** | ||
~ * 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. | ||
~ */ | ||
--> | ||
|
||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" | ||
xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws" | ||
xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs" | ||
xmlns:cxf="http://cxf.apache.org/blueprint/core" | ||
xsi:schemaLocation=" | ||
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd | ||
http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd | ||
http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd | ||
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd | ||
"> | ||
|
||
|
||
<cxf:bus> | ||
<cxf:features> | ||
<cxf:logging/> | ||
</cxf:features> | ||
</cxf:bus> | ||
|
||
<jaxrs:server id="docService" address="/docservice"> | ||
<jaxrs:serviceBeans> | ||
<ref component-id="docServiceBean" /> | ||
</jaxrs:serviceBeans> | ||
</jaxrs:server> | ||
|
||
<bean id="docServiceBean" class="docservice.service.DocServiceImpl"/> | ||
</blueprint> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
install -s mvn:org.apache.cxf.samples/wsdl_first_mtom/1.0.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!-- 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. --> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.apache.cxf.samples</groupId> | ||
<artifactId>wsdl_first_mtom</artifactId> | ||
<packaging>bundle</packaging> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<cxf.version>2.6.1</cxf.version> | ||
<cxf.xjc-utils.version>2.6.0</cxf.xjc-utils.version> | ||
</properties> | ||
<build> | ||
<defaultGoal>install</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<version>2.3.7</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
|
||
</instructions> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-codegen-plugin</artifactId> | ||
<version>${cxf.version}</version> | ||
<executions> | ||
<execution> | ||
<id>generate-sources</id> | ||
<phase>generate-sources</phase> | ||
<configuration> | ||
<wsdlOptions> | ||
<wsdlOption> | ||
<wsdl>src/main/resources/VertragsService.wsdl</wsdl> | ||
<bindingFiles> | ||
<bindingFile>src/main/resources/binding.xml</bindingFile> | ||
</bindingFiles> | ||
</wsdlOption> | ||
</wsdlOptions> | ||
</configuration> | ||
<goals> | ||
<goal>wsdl2java</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-frontend-jaxws</artifactId> | ||
<version>${cxf.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-transports-http-jetty</artifactId> | ||
<version>${cxf.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf.xjc-utils</groupId> | ||
<artifactId>cxf-xjc-runtime</artifactId> | ||
<version>${cxf.xjc-utils.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
<version>4.10</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
58 changes: 58 additions & 0 deletions
58
examples/wsdl_first_mtom/src/main/java/com/example/customerservice/client/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* 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 com.example.customerservice.client; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.activation.DataHandler; | ||
import javax.activation.DataSource; | ||
import javax.activation.FileDataSource; | ||
import javax.xml.ws.BindingProvider; | ||
import javax.xml.ws.soap.SOAPBinding; | ||
|
||
import org.example.vertragsservice.VertragsService; | ||
import org.example.vertragsservice.VertragsService_Service; | ||
|
||
public class Client { | ||
protected Client() { | ||
} | ||
|
||
public static void main(String args[]) throws Exception { | ||
VertragsService_Service vertragsServiceService = new VertragsService_Service(); | ||
|
||
VertragsService vertragsService = vertragsServiceService.getVertragsServiceSOAP(); | ||
BindingProvider provider = (BindingProvider)vertragsService; | ||
Map<String, Object> requestContext = provider.getRequestContext(); | ||
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8040/services/VertragsService"); | ||
SOAPBinding binding = (SOAPBinding)provider.getBinding(); | ||
binding.setMTOMEnabled(true); | ||
|
||
List<DataHandler> anlagen = new ArrayList<DataHandler>(); | ||
DataSource ds = new FileDataSource(new File("PDFUserGuide.pdf")); | ||
DataHandler anlage = new DataHandler(ds); | ||
anlagen.add(anlage ); | ||
vertragsService.anlegen("1", new Date(), anlagen ); | ||
|
||
System.exit(0); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
examples/wsdl_first_mtom/src/main/java/com/example/customerservice/server/Server.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* 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 com.example.customerservice.server; | ||
|
||
import javax.xml.ws.Endpoint; | ||
import javax.xml.ws.soap.SOAPBinding; | ||
|
||
import org.apache.cxf.interceptor.LoggingInInterceptor; | ||
import org.apache.cxf.interceptor.LoggingOutInterceptor; | ||
import org.apache.cxf.jaxws.EndpointImpl; | ||
|
||
public class Server { | ||
|
||
protected Server() throws Exception { | ||
System.out.println("Starting Server"); | ||
VertragsServiceImpl implementor = new VertragsServiceImpl(); | ||
EndpointImpl ep = (EndpointImpl)Endpoint.publish("http://localhost:9090/CustomerServicePort", | ||
implementor); | ||
SOAPBinding binding = (SOAPBinding)ep.getBinding(); | ||
binding.setMTOMEnabled(true); | ||
|
||
// Adding logging for incoming and outgoing messages | ||
ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor()); | ||
ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor()); | ||
} | ||
|
||
public static void main(String args[]) throws Exception { | ||
new Server(); | ||
System.out.println("Server ready..."); | ||
Thread.sleep(5 * 60 * 1000); | ||
System.out.println("Server exiting"); | ||
System.exit(0); | ||
} | ||
} |
Oops, something went wrong.