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

Method decode

soap-jakarta/src/main/java/feign/soap/SOAPDecoder.java:96–134  ·  view source on GitHub ↗
(Response response, Type type)

Source from the content-addressed store, hash-verified

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