Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 发送给调用方的Camel CXF响应消息-重复的WS-Security部分_Java_Apache Camel_Cxf - Fatal编程技术网

Java 发送给调用方的Camel CXF响应消息-重复的WS-Security部分

Java 发送给调用方的Camel CXF响应消息-重复的WS-Security部分,java,apache-camel,cxf,Java,Apache Camel,Cxf,我定义了一个点服务。消息的接收工作正常,但我正在生成的响应/确认消息有问题。消息中的WS-Security部分/操作保留在中,因此在响应中我有自己的WS-Security部分(签名时间戳)加上来自调用方/原始消息的WS-Security部分。 原始调用者不接受消息确认,我怀疑这就是问题所在(我有他们的签名,带有BinarySecuritySessionToken和我们自己的签名) 骆驼路线对于解决问题来说相当简单: from("myEndpoint") .transacted()

我定义了一个点服务。消息的接收工作正常,但我正在生成的响应/确认消息有问题。消息中的WS-Security部分/操作保留在中,因此在响应中我有自己的WS-Security部分(签名时间戳)加上来自调用方/原始消息的WS-Security部分。 原始调用者不接受消息确认,我怀疑这就是问题所在(我有他们的签名,带有BinarySecuritySessionToken和我们自己的签名)

骆驼路线对于解决问题来说相当简单:

from("myEndpoint")
    .transacted()
    .process(new PreProcessor())
    .to("mock:end")
我已将路线中的驼峰点定义为:

CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setAddress("http://0.0.0.0:8888/services/Service");
cxfEndpoint.setWsdlURL("Service.wsdl");
cxfEndpoint.setCamelContext(camelContext);
....
问题示例时间戳:

<wsu:Timestamp wsu:Id="TS-6757512FE17DCDC903153191998160526">                                   
  <wsu:Created>2018-07-18T13:19:41.605Z</wsu:Created>
  <wsu:Expires>2018-07-18T13:24:41.605Z</wsu:Expires>                                           
</wsu:Timestamp>
<u:Timestamp xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" u:Id="uuid-b2a1c0b2-8263-4afc-bc99-f8a46da80ce7-693">
  <u:Created>2018-07-18T13:19:42.905Z</u:Created>
  <u:Expires>2018-07-18T13:24:42.905Z</u:Expires>
</u:Timestamp>

2018-07-18T13:19:41.605Z
2018-07-18T13:24:41.605Z
2018-07-18T13:19:42.905Z
2018-07-18T13:24:42.905Z
响应消息的一般结构似乎很好,但我需要从消息中去掉WS-Security操作部分。 有没有办法剥离这些部分,或者我需要构建一个全新的消息?
如果您需要其他信息,请告诉我,谢谢。

因此我通过添加另一个用于删除安全标头的拦截器来修复它。 我想知道这是一个可以接受的办法,还是有更好的办法来解决这个问题

public class RemoveSecurityHeadersOutInterceptor extends AbstractSoapInterceptor
{    
  public RemoveSecurityHeadersOutInterceptor(String phase) {
    super(Phase.PRE_PROTOCOL);
  }

public void handleMessage(SoapMessage message) throws Fault
{
  List<Header> headers = message.getHeaders(); 
  headers.removeIf(h -> h.getName().getLocalPart().equals("Security"));
  }
}
公共类RemoveSecurityHeaderOutiterCeptor扩展了AbstractSoapInterceptor
{    
public RemoveSecurityHeaderOutinterCeptor(字符串阶段){
超级(阶段前协议);
}
public void handleMessage(SoapMessage消息)引发错误
{
List headers=message.getHeaders();
headers.removeIf(h->h.getName().getLocalPart().equals(“安全”));
}
}