Forum Discussion

jeremy_weber's avatar
jeremy_weber
New Contributor
15 years ago

SOAPUI Api and Basic auth

Im trying to follow the instructions here:  http://www.soapui.org/architecture/inte ... html  however am stuck when a wsdl/endpoint is behind basic auth.  I am setting username / password on the request, but it looks I need to set somewhere else as well.  Setting on the url causes the first NPE below.  The second NPE looks like its failing to launch the dialog to prompt me username/password.  So that may be a red herring.  Can anyone suggest on how to proceed?

Here is the code I am using to build my request:

        String requestData = soapBeginning + getInputDocument() + soapEnd;
        project = new WsdlProject();
 
              WsdlInterface iface = project.importWsdl(location + getServiceName()
              + "?wsdl", true)[0];
        WsdlOperation operation = (WsdlOperation) iface
              .getOperationByName(getOperation());
        request = operation.addNewRequest("My request");
        request.setUsername(getUsername());
        request.setPassword(getPassword());
        request.setRequestContent(requestData);


If the location of the wsdl i pass in looks like http://username:password@some.host:8080 ... wsdl  I receive a NPE

Progress: 2 - Loading [http://username:password@some.host:8080/services/someService?wsdl]
13:04:46,656 DEBUG [WsdlLoader] Getting wsdl component from [http://username:password@some.host:8080/services/someService?wsdl]
13:04:47,806 INFO  [WsdlLoader] Returning url credentials
13:04:47,836 INFO  [WsdlLoader] BaseURI was redirected to [http://some.host:8080/services/someService?wsdl]
Progress: 1 - Loading Definition from url
13:04:47,876 DEBUG [AbstractDefinitionContext] Loading Definition...
13:04:47,878 ERROR [AbstractDefinitionContext] Loading of definition failed for [http://username:password@some.host:8080/services/someService?wsdl]; java.lang.NullPointerException
13:04:47,878 ERROR [SoapUI] An error occured [java.lang.NullPointerException], see error log for details

12:53:03,859 ERROR [SoapUI] An error occured [java.lang.NullPointerException], see error log for details
java.lang.NullPointerException
  at com.eviware.soapui.impl.support.definition.support.InterfaceCacheDefinitionLoader.(InterfaceCacheDefinitionLoader.java:40)
  at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.createDefinitionLoader(WsdlContext.java:56)
  at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext.createDefinitionLoader(WsdlContext.java:1)
  at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext.cacheDefinition(AbstractDefinitionContext.java:261)


If i exclude the username/password on the url I get another NPE:

Progress: 2 - Loading [http://some.host:8080/services/someService?wsdl]
12:55:36,166 DEBUG [WsdlLoader] Getting wsdl component from [http://some.host:8080/services/someService?wsdl]
12:55:37,331 INFO  [WsdlLoader] some.host:8080 requires authentication with the realm 'Some security realm'
12:55:37,336 ERROR [HttpMethodDirector]
java.lang.NullPointerException
  at com.eviware.x.form.XFormFactory.createDialogBuilder(XFormFactory.java:19)
  at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader$WsdlCredentialsProvider.buildBasicDialog(UrlWsdlLoader.java:342)
  at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader$WsdlCredentialsProvider.access$1(UrlWsdlLoader.java:340)
  at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader$WsdlCredentialsProvider$ShowDialog.run(UrlWsdlLoader.java:373)