WebService调用异常401

时间:2013-05-11 10:31:55

标签: web-services webservice-client

您好我正在通过我的网络服务创建客户端。客户端生成成功,但是当我从java代码调用它时,它会抛出以下错误:

Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://ebs-uat.corp.chartercom.com/csg_cter/2.06/orderdetailservice.asmx?wsdl. It failed with: 
Server returned HTTP response code: 401 for URL: https://ebs-uat.corp.chartercom.com/csg_cter/2.06/orderdetailservice.asmx?wsdl.
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:151)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:133)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
at javax.xml.ws.Service.<init>(Service.java:56)
at com.charter.enterprise.billing.csg.orderdetails.OrderDetailServicePort.<init>(OrderDetailServicePort.java:68)
at com.charter.enterprise.billing.csg.orderdetails.OrderDetailServiceClient.main(OrderDetailServiceClient.java:18)

Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://ebs-uat.corp.chartercom.com/csg_cter/2.06/orderdetailservice.asmx?wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
at java.net.URL.openStream(URL.java:1010)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:793)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:251)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:118)
... 7 more

在创建webservice端口

时,它会在第一行引发异常
DataServicePort dataServicePort = new DataServicePort();

我的完整客户端类是:

public class OrderDetailServiceClient {
    @WebServiceRef
    private static OrderDetailServicePort orderDetailServicePort;
    private static OrderDetailService orderDetailService;

    public static void main(String[] args) {
        orderDetailServicePort = new OrderDetailServicePort();
        orderDetailService = orderDetailServicePort.getOrderDetailService();
        // Add your code to call the desired methods.

        System.out.println("Before calling method!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        verifyOrderDetail();
    }

    private static void verifyOrderDetail() {
        BindingProvider prov = (BindingProvider) orderDetailService;
        prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
            "CHTR\tst_aopebstest");
        prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
            "T$t_@0p3B$t#sT");
        orderDetailService = (OrderDetailService) prov;

        VerifyOrderDetailRequest verifyOrderDetailRequest = new VerifyOrderDetailRequest();

        VerifyOrderDetailResponse verifyOrderDetailResponse = orderDetailService
            .verifyOrderDetail(verifyOrderDetailRequest, null);

    }
}

我可以点击浏览器。它也在SoapUI中工作。我哪里错了? 任何建议将不胜感激。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

看起来您无法访问该网络服务,您是否尝试通过网络浏览器访问该网络服务?