Forum Discussion

Omegadash's avatar
Omegadash
New Contributor
9 years ago

WSDLImporter and Basic Auth

Hi, I am attempting to import a WSDL into a java project, the issue is that it keeps failing during the import due to the basic authentication.

 

When executing my output displays:

12:42:30,745 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 401 Unauthorized
12:42:30,748 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
12:42:30,748 DEBUG [HttpClientSupport$SoapUIHttpClient] Authentication required
12:42:30,749 DEBUG [HttpClientSupport$SoapUIHttpClient] exampleURL.com:443 requested authentication
12:42:30,752 INFO [WsdlLoader] Returning url credentials
12:42:30,754 DEBUG [HttpClientSupport$SoapUIHttpClient] Selected authentication options: [BASIC [complete=true]]

 

...and my error output displays the following exception:

java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.<init>(I)V
at org.apache.http.impl.auth.BasicScheme.authenticate(BasicScheme.java:168)
at org.apache.http.client.protocol.RequestAuthenticationBase.authenticate(RequestAuthenticationBase.java:120)
at org.apache.http.client.protocol.RequestAuthenticationBase.process(RequestAuthenticationBase.java:83)
at org.apache.http.client.protocol.RequestTargetAuthentication.process(RequestTargetAuthentication.java:80)
at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:132)
at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:166)
at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$SoapUIHttpRequestExecutor.preProcess(HttpClientSupport.java:106)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:485)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader$LoaderWorker.construct(UrlWsdlLoader.java:228)
at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader.load(UrlWsdlLoader.java:142)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.readCleanWsdlFrom(WsdlLoader.java:147)
at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:116)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:539)
at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:528)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:101)
at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:240)
at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:50)
at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:153)
at java.lang.Thread.run(Thread.java:745)

 

The code chunk used is as follows:

 

project = new WsdlProject("project");

System.setProperty("soapui.loader.username", username);
System.setProperty("soapui.loader.password", password);

wsdlInterface = WsdlImporter.importWsdl(project,URL);

 

2 Replies

    • rupert_anderson's avatar
      rupert_anderson
      Valued Contributor

      Hi,

       

      I haven't had time to do any testing, but have you tried passing the username and password as part of the url e.g. like http://username : password@www.mycorp.com/somewsdl.wsdl  ?

       

      As I was looking at the code for the WsdlLoader class and it seems to check whether the URL has an "authority" set and, if so, extracts the username and passord from it...

       

      public abstract class WsdlLoader extends AbstractDefinitionLoader implements WsdlDefinitionLoader {
          private String url;
          private String firstNewURI;
          private String last;
          private String username;
          private String password;
          protected static final Logger log = Logger.getLogger(WsdlLoader.class);
      
          public WsdlLoader(String url) {
              this.url = url;
      
              if (!PathUtils.isFilePath(url) && !PathUtils.isRelativePath(url)) {
                  // check for username/password
                  try {
                      URL u = new URL(url);
                      String authority = u.getAuthority();
                      if (authority != null) {
                          int ix1 = authority.indexOf('@');
                          int ix2 = authority.indexOf(':');
      
                          if (ix1 > ix2 && ix2 > 0) {
                              username = authority.substring(0, ix2);
                              password = authority.substring(ix2 + 1, ix1);
                          }
                      }

       Hope this works,

      Thanks,

      Rupert