小编Adr*_*ria的帖子

javax.xml.ws.WebServiceException:无法访问WSDL.回复:'401:未经授权'

我正在尝试访问我正在处理的项目的Web服务.我正在使用JAX-WS,应用程序部署在weblogic上.当我试图访问WS时,我得到以下异常:

javax.portlet.PortletException: javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl. It failed with: 
Response: '401: Unauthorized' for url: 'http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl'.
at com.bea.portlet.container.PortletStub.processAction(PortletStub.java:346)
at com.bea.portlet.container.AppContainer.invokeProcessAction(AppContainer.java:678)
........
Run Code Online (Sandbox Code Playgroud)

我阅读了很多关于问题的帖子,我尝试了不同类型的auth.我尝试在不同的用例中使用BindingProvider,basicHTTPAuth,禁用HostnameVerifier等但仍然没有结果.

以下是我的代码片段,作为最后一个尝试过的版本:

Authenticator.setDefault(new Authenticator() {
                    @Override
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(
                            username,
                            password.toCharArray());
                    }
                });


    ComputeUserProfileImplService computeUserProfileImplService = new ComputeUserProfileImplService(
    new URL(null, endpointURL, new sun.net.www.protocol.http.Handler()),
    new QName("http://xxx.xx.xxxxx.xxxxx.com/",
            "ComputeUserProfileImplService"));
    ComputeUserProfileImpl computeUserProfile = computeUserProfileImplService
    .getComputeUserProfileImplPort();
Run Code Online (Sandbox Code Playgroud)

ComputeUserProfileImplService代码如下所示:

private final static URL COMPUTEUSERPROFILEIMPLSERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.xxxxx.xxxxx.xx.xxxxx.cup.ComputeUserProfileImplService.class.getName());

static {
    URL url = null;
    try { …
Run Code Online (Sandbox Code Playgroud)

java wsdl weblogic jax-ws webservice-client

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×1

jax-ws ×1

weblogic ×1

webservice-client ×1

wsdl ×1