-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support of SoapHeader #1005
Comments
Hi, I have the same need. |
Hi, We have the same need here too !!! we need to pass security params in the header!! |
I suspect in the short term, you could extend the If we want to go the annotation route, we may custom |
Hi, we have the same needs. Using old systems connecting by soap and feign is great for this job |
Try extending a SOAPEncoder class: import feign.Headers;
import feign.RequestTemplate;
import feign.jaxb.JAXBContextFactory;
import feign.soap.SOAPEncoder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.stream.Stream;
public class CustomSOAPEncoder extends SOAPEncoder {
public CustomSOAPEncoder(JAXBContextFactory jaxbContextFactory) {
super(jaxbContextFactory);
}
@Override
public void encode(Object object, Type bodyType, RequestTemplate template) {
super.encode(object, bodyType, template);
Method method = template.methodMetadata().method();
try {
Headers headers = method.getDeclaredAnnotation(Headers.class);
Stream.of(headers.value())
.forEach(h -> {
String[] header = h.split(":");
if(header.length == 2) {
template.header(header[0], header[1].trim());
}
});
} catch (Exception ignored) {}
}
} |
@elesdoar that would add HTTP headers, but not a SOAP-ENV:Header in the Soap Envelope |
I just created a PR for an easy solution. This enables any kind of modification to the SOAPMessage before it's finally encoded. |
Nice! Thanks for the PR. |
Hi,
It would be great, if there could be some support of SoapHeaders when you are using Feign for legacy Soap calls. I just recently came to legacy API, where it was mandatory.
And having something like this would be absolutely amazing as headers might be marshalled objects.
Second best thing would be method annotation where you could define per method interceptor
@SoapHeader(MyJaxbHeaderInterceptor.class)
The simplest solution (which I chose as it is the simplest one and it fit my need) would be to add interceptor in builder (to encoder).
I created copy of SoapEncoder
SoapEncoderWithHeader(JAXBContextFactory jaxbContextFactory, MyJaxbHeaderInterceptor headerInterceptor)
and I only had to add following two lines in encode method:The text was updated successfully, but these errors were encountered: