Announcement Announcement Module
No announcement yet.
HTTP 401 with JaxRpcPortProxyFactoryBean when accessing WSDL Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP 401 with JaxRpcPortProxyFactoryBean when accessing WSDL

    I have a JAX-RPC service I am attempting to consume with Spring. The web service itself sits behind HTTP Basic Authentication.

    Using this Spring configuration:

    	<bean id="myWebService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
    	    <property name="serviceInterface" value=""/>
    	    <property name="wsdlDocumentUrl" value="..."/>
    	    <property name="endpointAddress" value="..."/>
    	    <property name="namespaceUri" value="..."/>
    	    <property name="serviceName" value="CompanyWebService"/>
    	    <property name="portName" value="CompanyWebServiceInterfacePort"/>
    	    <property name="portInterface" value=""/>
    	    <property name="username" value="username"/>
    	    <property name="password" value="password"/>
    	    <property name="maintainSession" value="true"/>
    Results in the following exception:

    nested exception is org.springframework.remoting.RemoteLookupFailureEx ception: Failed to initialize service for JAX-RPC port [{<WSDL NAMESPACE>}CompanyWebServiceInterfacePort];
    nested exception is javax.xml.rpc.ServiceException: modeler error: failed to parse document at "<WSDL URL>": Server returned HTTP response code: 401 for URL: <WSDL URL>
    If JaxRpcPortProxyFactoryBean has a property for Username and Password to set while accessing the web service, why does it not use this Username/Password to authenticate when fetching the WSDL?

    btw, seems like some what of a joke that the official Spring forums uses such a simple forum software that doesn't allow me to even post http or URLs inside of my code snippets. What in the world is the point of that?

  • #2
    I have the same problem.
    The wsdl itself is already protected and the Factory it not using username/password here.

    How can this be solved?


    • #3
      Username and Password for URL openConnection

      Try creating a and setting the default authenticator. You'll also need to extend JaxRpcPortProxyFactoryBean. Note, when you set the default Authenticator it is JVM global. Here's the code:

      class MyAuthenticator extends Authenticator {

      private String username;
      private String password;

      public MyAuthenticator(String username, String password) {
      this.userName = userName;
      this.password = password;

      protected PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication(username, password.toCharArray());



      Authenticator.setDefault(new MyAuthenticator());