简体   繁体   中英

How to add headers in a Soap Web service JAX-WS

I am new to java web service. I want to add headers to my web service I tried to add @WebParam(name = "noun", header = true) in my input parameters of web method. I tried something like this

@WebService(serviceName = "Server")
public class Server {
@WebMethod(operationName = "DeviceAccess")    
    public String DeviceAccess(@WebParam(name = "noun", header = true) String noun, @WebParam(name = "verb", header = true) String verb ) {
        String returnMessage=noun+verb;
        return returnMessage;
    }
} 

But when I try to test my web service using tool called 'storm' It shows that header parameters ie 'noun' and 'verb' in above case shows in body element of request Please help me

You can add response headers with custom Interceptor . In case of CXF you can extend org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor for this and then add it to your service with org.apache.cxf.interceptor.OutInterceptors annotation.

More info here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM