admin管理员组文章数量:1434960
The problem is that after adding JAX-WS to my project, specifically to the file that will be generated, I tested the generated file, but nothing related to the interceptor appeared. It seems like I didn’t add it at all, as no issues were shown, and the interceptor doesn’t work.
here is the generated file which it suppose it has the interceptor
package Services;
import javax.annotation.Resource;
import javax.jws.*;
import javax.xml.ws.*;
import javax.xml.ws.soap.SOAPBinding;
@HandlerChain(file = "C:/WEBLOGIC/wsbank/TPS/WEB-INF/src/Services/handler.xml")
@WebService(serviceName = "Virement")
public class Virement {
@Resource
private WebServiceContext wsCtx;
@WebMethod
public String WS43(
@WebParam(name = "NumeroDocument") Long numeroDocument,
@WebParam(name = "TypeDocument") Long typeDocument,
@WebParam(name = "RIBBeneficiaire") String ribBeneficiaire,
@WebParam(name = "Description") String description,
@WebParam(name = "RIBDonneurOrdre") String ribDonneurOrdre,
@WebParam(name = "Devise") String devise,
@WebParam(name = "Montant") Long montant
) {
WS43ImplGen ws43ImplGen = new WS43ImplGen();
//return ws43ImplGen.Execute_WS43(
// numeroDocument, typeDocument, ribBeneficiaire, description,
// ribDonneurOrdre, devise, montant, wsCtxr
return "test";
}
}
here is the handler chain xml file
<handler-chain xmlns=";>
<handler>
<handler-class>Services.ParameterValidationHandler</handler-class>
</handler>
</handler-chain>
here is the code logic of the interceptor
package Services;
import java.util.Collections;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPBody;
import java.util.Set;
public class ParameterValidationHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public boolean handleMessage(SOAPMessageContext context) {
System.out.println("done");
Boolean isOutbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (isOutbound) {
System.out.println("Outbound message - Skipping validation.");
} else {
System.out.println("Inbound message - Validating parameters...");
// Get the SOAP message
SOAPMessage message = context.getMessage();
try {
SOAPHeader header = message.getSOAPHeader();
SOAPBody body = message.getSOAPBody();
// Example of accessing the SOAP message parts, you can validate parameters here
System.out.println("SOAP Header: " + header);
System.out.println("SOAP Body: " + body);
// Add your parameter validation logic here
// For example, checking certain elements in the body
} catch (Exception e) {
e.printStackTrace();
}
}
// Return true to continue processing, false to block the message
return true;
}
@Override
public boolean handleFault(SOAPMessageContext context) {
System.out.println("Handling SOAP fault...");
return true; // You can handle faults here if necessary
}
@Override
public void close(MessageContext context) {
// Cleanup if needed
}
@Override
public Set<QName> getHeaders() {
// TODO Implement this method
return Collections.emptySet();
}
}
So here’s the problem, i need your help guys, because I’m going insane and thanks in advance for your help !
本文标签: javaJAXWS interceptor is not being triggerdStack Overflow
版权声明:本文标题:java - JAX-WS interceptor is not being triggerd - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745626806a2667021.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论