こんにちは私はスプリングソープクライアントにヘッダーを追加したいと思います。以下のようなClientAppConfigクラスがあります。スプリングソープクライアントにカスタムヘッダーを追加するには
@Configuration
public class ClientAppConfig {
@Bean
public Wss4jSecurityInterceptor wss4jSecurityInterceptor() {
Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
interceptor.setSecurementActions("Timestamp");
interceptor.setSecurementUsername("user");
interceptor.setSecurementPassword("*******");
return interceptor;
}
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan("com");
return marshaller;
}
@Bean
public SomeClient someClient(Jaxb2Marshaller marshaller) {
SomeClient client = new SomeClient();
client.setDefaultUri("http://test");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}
例クライアント:
@Component
public class SomeClient extends WebServiceGatewaySupport {
public SomeResponse someMethod(ArrayOfLong arrayOfLong) {
SomeRequest request = new SomeRequest();
request.setsomeId(arrayOfLong);
SomeResponse response = (SomeResponse) getWebServiceTemplate()
.marshalSendAndReceive(request, new SoapActionCallback(
"http://soapaction"));
return response;
}
}
そして、私はこのようなWSDLの要求を持っています。
<soapenv:Envelope xmlns:soapenv="http://envelope" xmlns:v1="http://Service">
<soapenv:Header xmlns:as="http://Schema">
<wsse:Security xmlns:wsse="http://wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>user</wsse:Username>
<wsse:Password>********</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<as:consumerContext xsi:type="as:IntWebAppContextType" xmlns:as="http://Schema" xmlns:xsi="http://XMLSchema-instance">
<consumerCode>someCode</consumerCode>
</as:consumerContext>
</soapenv:Header>
<soapenv:Body>
<v1:someReceived xmlns:ns3="http://Service" xmlns:ns2="http://Schema">
<v1:parameters>
<!--Optional:-->
<v1:someId>
<!--Zero or more repetitions:-->
<v1:long>111111111</v1:long>
</v1:someId>
</v1:parameters>
</v1:someReceived>
</soapenv:Body>
</soapenv:Envelope>
私はユーザー名とパスワードを追加したが、私はas:consumerContext
セクションを追加する必要があり、私は応答他の賢明イム取得中にエラーを取得するためconsumerCodeを取得する必要があります。どのように私は春のWS
私はorg.jvnet.jaxb2.maven2で生成しました。mavenプラグイン – mstykt
'wsimport'と同じことを行い、' ConsumerContext.java'を見つけ、それを入力して 'Header'の一部として設定します。 – Arpit
HeaderTypeクラスのみがあり、それは:consumerContext要素です。respoonseに含めるか、グローバルに設定するにはどうすればいいですか? – mstykt