-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding SOAP CoDec (+ JAXB modifications)
- Loading branch information
Showing
13 changed files
with
1,194 additions
and
27 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
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
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
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
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
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,50 @@ | ||
SOAP Codec | ||
=================== | ||
|
||
This module adds support for encoding and decoding SOAP Body objects via JAXB and SOAPMessage. It also provides SOAPFault decoding capabilities by wrapping them into the original `javax.xml.ws.soap.SOAPFaultException`, so that you'll only need to catch `SOAPFaultException` in order to handle SOAPFault. | ||
|
||
Add `SOAPEncoder` and/or `SOAPDecoder` to your `Feign.Builder` like so: | ||
|
||
```java | ||
public interface MyApi { | ||
|
||
@RequestLine("POST /getObject") | ||
@Headers({ | ||
"SOAPAction: getObject", | ||
"Content-Type: text/xml" | ||
}) | ||
MyJaxbObjectResponse getObject(MyJaxbObjectRequest request); | ||
|
||
} | ||
|
||
... | ||
|
||
JAXBContextFactory jaxbFactory = new JAXBContextFactory.Builder() | ||
.withMarshallerJAXBEncoding("UTF-8") | ||
.withMarshallerSchemaLocation("http://apihost http://apihost/schema.xsd") | ||
.build(); | ||
|
||
api = Feign.builder() | ||
.encoder(new SOAPEncoder(jaxbFactory)) | ||
.decoder(new SOAPDecoder(jaxbFactory)) | ||
.target(MyApi.class, "http://api"); | ||
|
||
... | ||
|
||
try { | ||
api.getObject(new MyJaxbObjectRequest()); | ||
} catch (SOAPFaultException faultException) { | ||
log.info(faultException.getFault().getFaultString()); | ||
} | ||
|
||
``` | ||
|
||
Because a SOAP Fault can be returned as well with a 200 http code than a 4xx or 5xx HTTP error code (depending on the used API), you may also use `SOAPErrorDecoder` in your API configuration, in order to be able to catch `SOAPFaultException` in case of SOAP Fault. Add it, like below: | ||
|
||
``` | ||
api = Feign.builder() | ||
.encoder(new SOAPEncoder(jaxbFactory)) | ||
.decoder(new SOAPDecoder(jaxbFactory)) | ||
.errorDecoder(new SOAPErrorDecoder()) | ||
.target(MyApi.class, "http://api"); | ||
``` |
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,88 @@ | ||
<!-- | ||
Copyright 2012-2018 The Feign Authors | ||
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. | ||
--> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>10.0.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>feign-soap</artifactId> | ||
<name>Feign SOAP</name> | ||
<description>Feign SOAP CoDec</description> | ||
|
||
<properties> | ||
<main.basedir>${project.basedir}/..</main.basedir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>feign-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>feign-jaxb</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>feign-core</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<activation> | ||
<jdk>11</jdk> | ||
</activation> | ||
|
||
<!-- | ||
JAX-WS was removed from java SDK on JEP 320 | ||
http://openjdk.java.net/jeps/320 | ||
--> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.xml.bind</groupId> | ||
<artifactId>jaxb-api</artifactId> | ||
<version>2.3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jaxb</groupId> | ||
<artifactId>jaxb-runtime</artifactId> | ||
<version>2.4.0-b180830.0438</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.xml.ws</groupId> | ||
<artifactId>jaxws-api</artifactId> | ||
<version>2.3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sun.xml.messaging.saaj</groupId> | ||
<artifactId>saaj-impl</artifactId> | ||
<version>1.5.0</version> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
Oops, something went wrong.