JAX WS client cannot authenticate

前端 未结 2 1617
小鲜肉
小鲜肉 2020-12-31 14:04

I\'m trying to consume a secure (HTTPS schema) web-service with help of standard JAVA 7 JAX WS tools. This web-service requires authentication.

I have already succes

2条回答
  •  醉梦人生
    2020-12-31 14:40

    Lets try a few things:

    1.) Do you know what kind of Authentication the server expects?

    2.) When you try to access https://reporting-stage.admp.mtv3.adtlgc.com/admp/ReportingService?wsdl do you see anything? e.g. i assume there is a IP-Whitelist or something and you will enter credentials there or similar? Because i cant see anything there.

    3.) When it comes to the code i authenticate to a secured webservice over HTTP this way:

    ReportingServiceService service new ReportingServiceService();
    ReportingService port = service.getReportingServicePort();
    BindingProvider binding = (BindingProvider) port;
    
    // Configure service endpoint (override defined one of the WSDL) 
    BindingProvider binding = (BindingProvider) port;
    binding.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https..");
    
    
    // Add HTTP Basic Authentification credentials to this request      
    binding.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "myuser");   
    binding.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "mypasswd");
    port.getCampaignRowById(14081);
    

    Set above endpoint propertie to whatever is stored in your wsdl's wsdl:port... part which i expect to look something like this (and should be the default...):

     
        
            
        
     
    

    Edit:

    The

    BindingProvider.ENDPOINT_ADDRESS_PROPERTY
    

    is used to set the target-endpoint at runtime. So if the webservice has a different endpoint than the one in the wsdl make sure to set it to the actual endpoint this way.

提交回复
热议问题