xfire客户端访问wse3的.net webservice报错:无法理解 SOAP 头 Security。(分不够我再加)
我在Client端这么设置的:
public static void setConfig(ServiceSoap var) {
WSS4JOutHandler config = new WSS4JOutHandler();
config.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE );
config.setProperty(WSHandlerConstants.SIG_PROP_FILE,
"outsecurity_sign.properties");
config.setProperty(WSHandlerConstants.ENC_PROP_FILE,
"outsecurity_sign.properties");
config.setProperty(WSHandlerConstants.SIG_KEY_ID, "SKIKeyIdentifier");
config.setProperty(WSHandlerConstants.ENC_KEY_ID, "SKIKeyIdentifier");
config.setProperty(WSHandlerConstants.USER, "tomcat-cl");
config.setProperty(WSHandlerConstants.ENCRYPTION_USER, "localhost");
config.setProperty(WSHandlerConstants.ENC_SYM_ALGO, "http://www.w3.org/2001/04/xmlenc#aes128-cbc");
config.setProperty(WSHandlerConstants.ENC_KEY_TRANSPORT, "http://www.w3.org/2001/04/xmlenc#rsa-1_5");
config.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, UtPasswordHandler.class.getName());
org.codehaus.xfire.client.Client.getInstance(var).addOutHandler(new DOMOutHandler());
org.codehaus.xfire.client.Client.getInstance(var).addOutHandler(config);
}
我在webservice端获取到的请求soap如下:
<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
\n<soap:Header>
\n<wsse:Security soap:mustUnderstand=\"1\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">
<ds:Signature Id=\"Signature-10580099\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">
\n<ds:SignedInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">
\n<ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" />\n<ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" />\n<ds:Reference URI=\"#id-22676229\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">
\n<ds:Transforms xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">
\n<ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" />\n
</ds:Transforms>\n<ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" />\n<ds:DigestValue xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">x8jxMor8V5pIWiWSnj8ePqKPoxU=</ds:DigestValue>\n
</ds:Reference>\n
</ds:SignedInfo>\n<ds:SignatureValue xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\nUJtl+4hePRm/LEPqj88XOGEl1BPop7FKvSK5LQHThm18OG/C8a1wKHNF3RHunEXvlgERh2V9FMM+\nINvsFtUamoYTyr2itFiL3IsSSCZMUHEtFqzeAwfM80OMh+yyIxlSJCOXNs8nvey5reER281v45we\nvUa28P50Zl0K/m9RB7M=\n</ds:SignatureValue>\n<ds:KeyInfo Id=\"KeyId-10690075\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">
\n<wsse:SecurityTokenReference wsu:Id=\"STRId-17308974\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">
<wsse:KeyIdentifier EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\" ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier\">/XtQaHLKr0UL3K/LRFDq+/6a6zE=</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>\n
</ds:KeyInfo>\n
</ds:Signature>
</wsse:Security>
</soap:Header><soap:Body wsu:Id=\"id-22676229\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">
<HelloWorld xmlns=\"http://tempuri.org/\" />
</soap:Body>
</soap:Envelope>
处理时报如下异常: System.Web.Services.Protocols.SoapHeaderException: 无法理解 SOAP 头 Security。
我怀疑是不是"\n"的问题,怎么才能去掉"\n"?