2017-03-22 11 views
9

Hi utworzyć kod zużywają usługi SOAP,SOAP WS-Addressing nieruchomość Wss4jSecurityInterceptor z Java

Dla Authentication Header użyłem Wss4jSecurityInterceptor zestaw do informacji nagłówka.

Dostaję odpowiedź nie jak poniżej

Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: Required element {http://www.w3.org/2005/08/addressing}Action is missing 

Mój kod konfiguracji jak poniżej

@Configuration 
public class SoapClientConfig { 

    @Bean 
    public Jaxb2Marshaller marshaller() { 
     Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); 
     marshaller.setContextPath("com.xyz.client"); 
     marshaller.setCheckForXmlRootElement(false); 
     return marshaller; 
    } 

    @Bean 
    public MyClient myClient(Jaxb2Marshaller marshaller) throws Exception { 
     MyClient client = new MyClient(); 
     client.setDefaultUri("https://localhost:8080/ws/service"); 
     client.setMarshaller(marshaller); 
     client.setUnmarshaller(marshaller); 

     ClientInterceptor[] interceptors = new ClientInterceptor[] {securityInterceptor()}; 

     client.setInterceptors(interceptors); 
     return client; 
    } 

    @Bean 
    public Wss4jSecurityInterceptor securityInterceptor() { 
     Wss4jSecurityInterceptor wss4jSecurityInterceptor = new Wss4jSecurityInterceptor(); 
     wss4jSecurityInterceptor.setSecurementActions("UsernameToken"); 
     wss4jSecurityInterceptor.setSecurementMustUnderstand(true); 
     wss4jSecurityInterceptor.setSecurementPasswordType("PasswordText"); 
     wss4jSecurityInterceptor.setSecurementUsername("XXXXXXXXXXX"); 
     wss4jSecurityInterceptor.setSecurementPassword("XXXXXXXX"); 
     return wss4jSecurityInterceptor; 
    } 
} 

Czy ktoś może zasugerować mi, co mi brakuje?

Jeśli spróbuję od SOAPUI, działa dobrze. Jeśli ustawię WS-Addressing = false z SOAPUI, podając ten sam błąd, So Issue z ustawioną właściwością WS-Addressing z powyższym kodem. Jak mogę?

+0

Mam rozwiązanie powyższego problemu tutaj ... https://stackoverflow.com/questions/43974784/remote-soap-web-service-keeps-breaking-connection/44154445#44154445 –

Odpowiedz

4

Czy używasz WebServiceTemplate do wysłania żądania? Jeśli tak, można zrobić coś takiego:

ActionCallback callback = new ActionCallback(
        new URI("action uri")); 

Tutaj należy podać rzeczywistą lokalizację uri działania zamiast „uri działania”. Następnie zrobić

getWebServiceTemplate().marshalSendAndReceive(request, callback) 
+0

Mój nagłówek SOAP już to zawiera Informacje o działaniu. Zajmuję się także własnością, a następnie dostaję adres adresowy –

+0

. Czy mógłbyś napisać cały kod dotyczący składania i wysyłania zleceń? –

+0

Kwestia jest dziwna, że ​​zależy od sekwencji działań. Zdefiniuj działanie przed elementem bezpieczeństwa, pokazuje błąd. Jeśli zdefiniuję działanie po zabezpieczeniu, to działa. –

Powiązane problemy