Я использую основанный на действии подход к ws-security, поскольку WSDL, к которому я подключаюсь, не содержит политики безопасности. Код для перехватчика и безопасности ниже.
Я получаю сообщение об ошибке от сервера, указывающее, что мой двоичный токен безопасности не закодирован в base 64. Это был скребок головы, так как он, кажется, и указывает на это в описании типа. Затем я заметил, что некоторые символы заменяются escape-символами XML. Если я грубо принудительно отправляю сообщение, где эти символы возвращаются, сервер отвечает, поэтому я подозреваю, что они не преобразуют их обратно при получении.
Как мне остановить экранирование заголовка?
Вот код, который я использую для настройки моего клиента:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean( );
factory.setServiceClass( Operations.class );
factory.setAddress( serviceUrl );
Map< String, Object > properties = Maps.newHashMap( );
properties.put( "mtom-enabled", "false" );
factory.setProperties( properties );
outProps.put( "cryptoProperties", sig_props );
outProps.put( WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT );
outProps.put( WSHandlerConstants.USER, apiKeyPairAlias );
outProps.put( WSHandlerConstants.SIG_PROP_REF_ID, "cryptoProperties" );
outProps.put( WSHandlerConstants.ENC_PROP_REF_ID, "cryptoProperties" );
outProps.put( WSHandlerConstants.SIG_KEY_ID, "DirectReference" );
outProps.put( WSHandlerConstants.ENC_KEY_ID, "DirectReference" );
outProps.put( WSHandlerConstants.SIGNATURE_USER, apiKeyPairAlias );
outProps.put( WSHandlerConstants.ENCRYPTION_USER, apiKeyPairAlias );
outProps.put( WSHandlerConstants.PW_CALLBACK_REF, new ClientPasswordHandler( ) );
outProps.put( WSHandlerConstants.STORE_BYTES_IN_ATTACHMENT, "true" );
outProps.put( WSHandlerConstants.USE_SINGLE_CERTIFICATE, "false" );
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor( outProps );
factory.getOutInterceptors( ).add( wssOut );
Map< String, Object > inProps = Maps.newHashMap( );
inProps.put( WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT );
inProps.put( "cryptoProperties", sig_props );
outProps.put( WSHandlerConstants.SIG_PROP_REF_ID, "cryptoProperties" );
outProps.put( WSHandlerConstants.ENC_PROP_REF_ID, "cryptoProperties" );
outProps.put( WSHandlerConstants.PW_CALLBACK_REF, new ClientPasswordHandler( ) );
WSS4JInInterceptor wssIn = new WSS4JInInterceptor( inProps );
factory.getInInterceptors( ).add( wssIn );