MCPcopy Index your code
hub / github.com/OpenFeign/feign / decode

Method decode

soap/src/main/java/feign/soap/SOAPDecoder.java:100–138  ·  view source on GitHub ↗
(Response response, Type type)

Source from the content-addressed store, hash-verified

98 }
99
100 @Override
101 public Object decode(Response response, Type type) throws IOException {
102 if (response.status() == 404) return Util.emptyValueOf(type);
103 if (response.body() == null) return null;
104 while (type instanceof ParameterizedType) {
105 ParameterizedType ptype = (ParameterizedType) type;
106 type = ptype.getRawType();
107 }
108 if (!(type instanceof Class)) {
109 throw new UnsupportedOperationException(
110 "SOAP only supports decoding raw types. Found " + type);
111 }
112
113 try {
114 SOAPMessage message =
115 MessageFactory.newInstance(soapProtocol)
116 .createMessage(null, response.body().asInputStream());
117 if (message.getSOAPBody() != null) {
118 if (message.getSOAPBody().hasFault()) {
119 throw new SOAPFaultException(message.getSOAPBody().getFault());
120 }
121
122 Unmarshaller unmarshaller = jaxbContextFactory.createUnmarshaller((Class<?>) type);
123
124 if (this.useFirstChild) {
125 return unmarshaller.unmarshal(message.getSOAPBody().getFirstChild());
126 } else {
127 return unmarshaller.unmarshal(message.getSOAPBody().extractContentAsDocument());
128 }
129 }
130 } catch (SOAPException | JAXBException e) {
131 throw new DecodeException(response.status(), e.toString(), response.request(), e);
132 } finally {
133 if (response.body() != null) {
134 response.body().close();
135 }
136 }
137 return Util.emptyValueOf(type);
138 }
139
140 public static class Builder {
141 String soapProtocol = SOAPConstants.DEFAULT_SOAP_PROTOCOL;

Calls 10

emptyValueOfMethod · 0.95
bodyMethod · 0.65
asInputStreamMethod · 0.65
statusMethod · 0.45
getRawTypeMethod · 0.45
newInstanceMethod · 0.45
createUnmarshallerMethod · 0.45
toStringMethod · 0.45
requestMethod · 0.45
closeMethod · 0.45

Tested by 4

decodesSoapMethod · 0.76