- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当将 MTOM ENABLE 设置为 true 时,我想避免自动生成 apache cxf(版本 3.0.4)中包含的 xop,我该怎么做?例如,我有 SOAP 服务。它支持mtom但不支持xop包含注释,所以它拒绝了我的请求:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
<soap:Body>
<ns2:receiveSip xmlns:ns2="http://sip.receive.core.iris.eng.it" xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<ns2:sipReceive>
<tipoSip>?</tipoSip>
<tipoProtezione>?</tipoProtezione>
<improntaAlgoritmo>SHA-256</improntaAlgoritmo>
<improntaCodifica>HEX</improntaCodifica> <impronta>9e830c2ac56eca00023b17e3c17ed1014e055f960c3ee4778a84aa02c6dafcb9</impronta>
</ns2:sipReceive>
<arg1>
<dh>
**<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:92dc39d3-e3d5-4aa2-a9cb-7582483934a4-1@cxf.apache.org"/>**
</dh>
</arg1>
</ns2:receiveSip>
</soap:Body>
</soap:Envelope>
我如何设置我的请求:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/>
<soap:Body>
<ns2:receiveSip xmlns:ns2="http://sip.receive.core.iris.eng.it" xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<ns2:sipReceive>
<tipoSip>?</tipoSip>
<tipoProtezione>?</tipoProtezione>
<improntaAlgoritmo>SHA-256</improntaAlgoritmo>
<improntaCodifica>HEX</improntaCodifica> <impronta>9e830c2ac56eca00023b17e3c17ed1014e055f960c3ee4778a84aa02c6dafcb9</impronta>
</ns2:sipReceive>
<arg1>
<dh>**cid:92dc39d3-e3d5-4aa2-a9cb-7582483934a4**</dh>
</arg1>
</ns2:receiveSip>
</soap:Body>
</soap:Envelope>
所以最后我只想替换:
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:92dc39d3-e3d5-4aa2-a9cb-7582483934a4-1@cxf.apache.org"/>
与
cid:940325888173
怎样才能得到这个结果呢?在更新的版本中,有一个参数 https://ws.apache.org/wss4j/apidocs/org/apache/wss4j/common/ConfigurationConstants.html#EXPAND_XOP_INCLUDE ,我如何在旧版本中复制?
这里是我使用的java代码:
public static <T> T buildServerWsdl(String endpointWsdl,final String username,final String password,
final Class<T> serviceClass,boolean ignoreSSLCertificate,boolean useAuthorizationBasic,Map<String,String> supplierheaders) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException{
//Controllo wsdlurl
URL wsdlURL;
java.io.File wsdlFile = new java.io.File(endpointWsdl);
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(endpointWsdl);
}
System.out.println(wsdlURL);
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(serviceClass);
factory.setAddress(endpointWsdl);
//Abilita il loggin in ingresco ed uscita dei messaggi soap!
factory.getInInterceptors().add(new LoggingInInterceptor(4*1024));
factory.getOutInterceptors().add(new LoggingOutInterceptor(4*1024));
@SuppressWarnings("unchecked")
T server = (T) factory.create();
// The BindingProvider interface provides access to the protocol binding and
// to the associated context objects for request and response message processing.
BindingProvider prov = (BindingProvider)server;
Binding binding = prov.getBinding();
((SOAPBinding)binding).setMTOMEnabled(true);
//Add handlers to the binding jaxb
java.util.List<javax.xml.ws.handler.Handler> handlers = binding.getHandlerChain();
handlers.add(new JaxWsLoggingHandler());
binding.setHandlerChain(handlers);
Map<String, Object> req_ctx = prov.getRequestContext();
req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointWsdl);
Map<String, List<String>> headers = new HashMap<String, List<String>>();
if(username != null && password != null){
headers.put("Username", Arrays.asList(username));
headers.put("Password", Arrays.asList(password));
//headers.put("Content-Type", Arrays.asList("text/xml")); //necessario specificare se si usa schema-core invece di XmlSchema
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
if(supplierheaders !=null && supplierheaders.size() > 0){
prov.getRequestContext().putAll(supplierheaders);
for(Map.Entry<String, String> entry : supplierheaders.entrySet()){
headers.put(entry.getKey(), Arrays.asList(entry.getValue()));
}
}
Authenticator myAuth = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password.toCharArray());
}
};
Authenticator.setDefault(myAuth);
}
if(useAuthorizationBasic){
String authorization = new sun.misc.BASE64Encoder().encode((username+":"+password).getBytes());
headers.put("Authorization", Arrays.asList("Basic " + authorization));
req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
//MessageContext mctx = wsctx.getMessageContext();
Map<String, List<String>> http_headers = (HashMap<String, List<String>>) req_ctx.get(MessageContext.HTTP_REQUEST_HEADERS);
List list = (List) http_headers.get("Authorization");
if (list == null || list.size() == 0) {
throw new RuntimeException("Authentication failed! This WS needs BASIC Authentication!");
}
String userpass = (String) list.get(0);
userpass = userpass.substring(5);
byte[] buf = org.apache.commons.codec.binary.Base64.decodeBase64(userpass.getBytes());
String credentials = new String(buf);
String usernamex = null;
String passwordx = null;
int p = credentials.indexOf(":");
if (p > -1) {
usernamex = credentials.substring(0, p);
passwordx = credentials.substring(p+1);
}
else {
throw new RuntimeException("There was an error while decoding the Authentication!");
}
// This should be changed to a DB / Ldap authentication check
if (usernamex.equals(username) && passwordx.equals(password)) {
//System.out.println("============== Authentication Basic OK =============");
}
else {
throw new RuntimeException("Authentication failed! Wrong username / password!");
}
}
//Client cl = ClientProxy.getClient(server);
org.apache.cxf.endpoint.Client cl = org.apache.cxf.frontend.ClientProxy.getClient(server);
//=============================================================================================
// Set up WS-Security Encryption
// Reference: https://ws.apache.org/wss4j/using.html
Map<String, Object> inProps = new HashMap<String, Object>();
//props.put(ConfigurationConstants.EXPAND_XOP_INCLUDE_FOR_SIGNATURE, false);
//props.put(ConfigurationConstants.EXPAND_XOP_INCLUDE, false);
//inProps.put("expandXOPIncludeForSignature", false);
//inProps.put("expandXOPInclude", false);
//WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor(inProps);
//ClientProxy.getClient(client).getOutInterceptors().add(wss4jOut);
//cl.getInInterceptors().add(wss4jOut);
//cl.getOutInterceptors();
//==============================================================================================
HTTPConduit httpConduit = (HTTPConduit) cl.getConduit();
//disable ssl certificate handshake
if(ignoreSSLCertificate){
String targetAddr = httpConduit.getTarget().getAddress().getValue();
if (targetAddr.toLowerCase().startsWith("https:")) {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {return new java.security.cert.X509Certificate[0];}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
} };
// Ignore differences between given hostname and certificate hostname
//HostnameVerifier hv = new HostnameVerifier(){public boolean verify(String hostname, SSLSession session) { return true; }};
TLSClientParameters tlsParams = new TLSClientParameters();
tlsParams.setTrustManagers(trustAllCerts);
tlsParams.setDisableCNCheck(true);
httpConduit.setTlsClientParameters(tlsParams);
//SSLContext sc = SSLContext.getInstance("SSL");
//sc.init(null, trustAllCerts, new SecureRandom());
}
}
AuthorizationPolicy authorizationPolicy = httpConduit.getAuthorization();
authorizationPolicy.setUserName(username);
authorizationPolicy.setPassword(password);
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(10000);//10sec
httpClientPolicy.setReceiveTimeout(60000);
httpClientPolicy.setContentType("application/soap+xml");
httpConduit.setClient(httpClientPolicy);
return server;
}
最佳答案
我们在 jboss-cxf-client 4.3.7 版本中也遇到了同样的问题。
似乎有多种方法可以禁用 CXF,但没有一种方法适用于我们使用的库版本。出于文档目的,这里列出了对我们不起作用的各种方法:
// Method 1
bindingProvider.getRequestContext().put("mtom-enabled", Boolean.FALSE);
bindingProvider.getRequestContext().put("write.attachments", Boolean.FALSE);
// Method 2
SOAPBinding binding = (SOAPBinding) (((BindingProvider) bindingProvider).getBinding());
binding.setMTOMEnabled(false);
由于 CXF 中的错误导致无法禁用自动转换,因此该方法不起作用。解决方法是将自动转换的阈值设置为最大值。为此,请将其作为一项功能添加到您的端口
new javax.xml.ws.soap.MTOMFeature(false, Integer.MAX_VALUE)
这为我们解决了问题。
关于java - 在 apache cxf 3.0.X 中为 WSS4JOutInterceptor 设置 EXPAND_XOP_INCLUDE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46038257/
我希望开始在服务器上使用 javascript,最有可能使用 node.js,以及使用 websockets 与客户端通信。但是,似乎没有很多关于使用 TLS 和 wss://处理程序的加密 webs
最近几天一直在为这个错误而苦苦挣扎 Authentication of type {http://service.soap.xcompany.com}AuthenticationHeader had
我正在使用 jax-ws 从 JAVA 调用使用 WS-Security 的 SOAP 服务。问题是响应包含一些 MustUnderstand header ,并且我收到 Element notund
我正在使用 .net 中开发的 Web 服务,该服务接受用户名和密码作为 SOAP header 的一部分。我创建了 SOAPHandler 来创建 header 。 我打印了如下消息: x
Web 服务托管在没有 Internet 连接的服务器上 我正在使用 SOAPUI 访问 Web 服务 url 并进行测试 但得到以下错误信息任何帮助真的很感激
我浏览了以下链接:SOAPFaultException "MustUnderstand headers (oasis-200401-wss-wssecurity-secext-1.0.xsd) are
可以使用CF10的人确认CF10是否支持安全的websocket wss://吗? http://blog.kaazing.com/2012/02/28/html5-websocket-securit
我有一个使用安全 websocket 的应用程序,但我遇到了麻烦。 我想使用wireshark 来调试问题,但是我无法找出正确的参数来放入wireshark 来监控和显示使用HTTPS 的安全Web
我有一个 Node 服务器 (Meteor.js),它应该使用 websockets 与另一台服务器进行通信。由于通信是在不涉及直接用户的服务器之间进行的,因此我选择使用自签名证书。 在哪里添加来自
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭 8 年前。 Improve
在为 SharePoint 开发复杂功能时,推荐的数据存储方法是什么?您应该将自己限制在 SP 列表以及随之而来的所有限制中,还是使用您自己的数据库,或者在 SP 数据库中创建表? 最佳答案 这实际上
首先,一点背景知识:我们有一个基于 WSS 3.0 的 Intranet 站点,该站点托管在 的服务器上。 DOMAIN_A.LOCAL 并设置为使用集成 Windows 身份验证根据 的 Activ
可以通过 IP 和 DNS 访问 Web 服务。 使用以下命令创建包含 DNS 作为通用名称以及 DNS 和 IP 作为 subjectAlternativeName 的自签名证书 openssl r
我在使用 HTTPS => WS 通信时遇到问题,但找不到解决方法。 我正在使用 Symfony 4.1 和 Ratchet WsServer。服务器通过 9090 端口上的 Symfony 命令启动
有没有办法查看Websocket流量? 只有 Websocket header 在初始握手时可见。 响应后一切都消失了: Connection Upgrade Sec-WebSocket-Accep
SharePoint 的搜索框存在问题。每当我们尝试搜索某些内容时,我们都会得到: Unable to validate data. at System.Web.Configuration.Machi
我是java新手。我想像这样连接到网络套接字: import java.net.URI; import java.net.URISyntaxException; public class PrimeB
我将网站移至 https://。在 http 到套接字上有一个通过 ws://sitename.com: 3003 的连接,现在它们必须在 wss://sitename.com: 3003 上可用。我
我正在尝试使用 nginx 反向代理将 websocket 连接 ws://升级到 wss://https://github.com/nicokaiser/nginx-websocket-proxy/
我发现有些移动网络提供商本身并不支持端口 80,但他们确实支持端口 443,我觉得这有点奇怪。无论如何,我无能为力,导致我从端口 80 切换到端口 433,使用 wss:// 代替 ws://。 我想
我是一名优秀的程序员,十分优秀!