SOAP client basic auth: HTTP response '401: Unauthorized'

SzZ

I'm trying to creat a SOAP client that has to call a server that uses http basic authentication. I get the following error:

    org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
...
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with http://localhost:8080/SpringMVCTest/services/ContractService?wsdl=ContractService.wsdl

My app-config.xml is:

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:security="http://www.springframework.org/schema/security"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/security  
    http://www.springframework.org/schema/security/spring-security-3.1.xsd">  

    <security:http auto-config="true">  
        <security:intercept-url pattern="/services/*"/>  
        <security:http-basic/>  
    </security:http>  

    <security:authentication-manager>
       <security:authentication-provider>
           <security:user-service>
           <security:user name="wsuser1" password="pw123" authorities="wsuser" />
           </security:user-service>
       </security:authentication-provider>
    </security:authentication-manager>

    <bean id="client" class="hu.bz.ikti.insurance.service.insurer.ContractService"
        factory-bean="clientFactory" factory-method="create"/>

    <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
        <property name="serviceClass" value="hu.bz.ikti.insurance.service.insurer.ContractService"/>
        <property name="address" value="http://localhost:8080/SpringMVCTest/services/ContractService?wsdl=ContractService.wsdl"/>
    </bean>

</beans>

The http basic auth is configured in the servers web.xml:

   <security-constraint>  
    <web-resource-collection>  
      <url-pattern>/services/*</url-pattern>  
    </web-resource-collection>  
    <auth-constraint>  
      <role-name>wsuser</role-name>  
    </auth-constraint>  
  </security-constraint>  
  <login-config>  
    <auth-method>BASIC</auth-method>  
  </login-config>  
  <security-role>  
    <role-name>webservice</role-name>  
  </security-role>

In tomcat-users.xml the user is added:

<user username="wsuser1" password="pw123" roles="wsuser"/>

I can open the wsdl in the browser giving username/password. What can cause this 401: Unauthorized error in the client?

Syon

According to the CXF documentation here:

https://cxf.apache.org/docs/jax-ws-configuration.html (see Configuring a Spring Client (Option 2))

The correct way to set the username and password is by using the username and password properties in your clientFactory bean configuration.

그래서 이것을 clientFactory안에 추가하십시오 .

<property name="username" value="yourUsername"/>
<property name="password" value="yourPassword"/>

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

HTTP Basic Auth Handler Error in Python

분류에서Dev

jquery ajax를 사용하여 401 Unauthorized http 응답 포착

분류에서Dev

401 UnAuthorized-이 요청에는 HTTP 인증이 필요합니다-Payara / Glassfish

분류에서Dev

401 Unauthorized Request Discord API with OAuth

분류에서Dev

Android Push Notification unauthorized error 401

분류에서Dev

cloud endpoints return error 401 unauthorized request

분류에서Dev

Https upload MultipartForm returns 401 unauthorized

분류에서Dev

Micropython ESP8266 Twilio 401 UNAUTHORIZED

분류에서Dev

Non-standard HTTP response codes: recommended client behaviour

분류에서Dev

Fitbit의 Unauthorized_client

분류에서Dev

Spring WS Client — KeyStore / TrustStore 및 Credentials (Basic Auth)를 사용한 인증

분류에서Dev

Symfony 2 SOAP CLIENT

분류에서Dev

JWT 토큰 오류 401 Unauthorized in .net core 3.1

분류에서Dev

401 Unauthorized when using s3 API for Swift Openstack

분류에서Dev

DotNetNuke Service API Authorization throwing 401 Unauthorized code

분류에서Dev

TokenResponseException을 가져 오는 중 : 401 Unauthorized

분류에서Dev

Bonsai Elasticsearch 애드온 : 401 Unauthorized Error

분류에서Dev

Django : Http404, RAISE EXCEPTION not RESPONSE와 같은 Http401 및 Http403 예외를 발생시키는 방법

분류에서Dev

How to put SOAP response into UITableView?

분류에서Dev

HTTP Request with No HTTP Response

분류에서Dev

Symfony - OAuth and basic auth together

분류에서Dev

Groovy Transform Vector from soap Response

분류에서Dev

json response handling from soap wsdl

분류에서Dev

200 ACT HTTP Response

분류에서Dev

Geolite2를 당기는 MaxMind는 401 Unauthorized를 얻습니다.

분류에서Dev

어댑터가 생성 되어도 401 Unauthorized 반환

분류에서Dev

You Tube 비디오 업로드 "401 Unauthorized"youtube-data-api 사용

분류에서Dev

( "NetworkError : 401 Unauthorized) JavaScript에서 메서드 뒤의 코드 호출

분류에서Dev

Google에서 401 Unauthorized (NAT 라우터)를 반환합니다.

Related 관련 기사

  1. 1

    HTTP Basic Auth Handler Error in Python

  2. 2

    jquery ajax를 사용하여 401 Unauthorized http 응답 포착

  3. 3

    401 UnAuthorized-이 요청에는 HTTP 인증이 필요합니다-Payara / Glassfish

  4. 4

    401 Unauthorized Request Discord API with OAuth

  5. 5

    Android Push Notification unauthorized error 401

  6. 6

    cloud endpoints return error 401 unauthorized request

  7. 7

    Https upload MultipartForm returns 401 unauthorized

  8. 8

    Micropython ESP8266 Twilio 401 UNAUTHORIZED

  9. 9

    Non-standard HTTP response codes: recommended client behaviour

  10. 10

    Fitbit의 Unauthorized_client

  11. 11

    Spring WS Client — KeyStore / TrustStore 및 Credentials (Basic Auth)를 사용한 인증

  12. 12

    Symfony 2 SOAP CLIENT

  13. 13

    JWT 토큰 오류 401 Unauthorized in .net core 3.1

  14. 14

    401 Unauthorized when using s3 API for Swift Openstack

  15. 15

    DotNetNuke Service API Authorization throwing 401 Unauthorized code

  16. 16

    TokenResponseException을 가져 오는 중 : 401 Unauthorized

  17. 17

    Bonsai Elasticsearch 애드온 : 401 Unauthorized Error

  18. 18

    Django : Http404, RAISE EXCEPTION not RESPONSE와 같은 Http401 및 Http403 예외를 발생시키는 방법

  19. 19

    How to put SOAP response into UITableView?

  20. 20

    HTTP Request with No HTTP Response

  21. 21

    Symfony - OAuth and basic auth together

  22. 22

    Groovy Transform Vector from soap Response

  23. 23

    json response handling from soap wsdl

  24. 24

    200 ACT HTTP Response

  25. 25

    Geolite2를 당기는 MaxMind는 401 Unauthorized를 얻습니다.

  26. 26

    어댑터가 생성 되어도 401 Unauthorized 반환

  27. 27

    You Tube 비디오 업로드 "401 Unauthorized"youtube-data-api 사용

  28. 28

    ( "NetworkError : 401 Unauthorized) JavaScript에서 메서드 뒤의 코드 호출

  29. 29

    Google에서 401 Unauthorized (NAT 라우터)를 반환합니다.

뜨겁다태그

보관