View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.actions.project;
14  
15  import com.eviware.soapui.impl.WsdlInterfaceFactory;
16  import com.eviware.soapui.impl.wsdl.WsdlProject;
17  import com.eviware.soapui.model.iface.Interface;
18  import com.eviware.soapui.support.UISupport;
19  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
20  
21  /***
22   * Adds a WsdlInterface to a WsdlProject from a URL
23   * 
24   * @author Ole.Matzura
25   */
26  
27  public class AddInterfaceActionFromURL extends AbstractSoapUIAction<WsdlProject>
28  {
29  	public static final String SOAPUI_ACTION_ID = "AddInterfaceActionFromURL";
30  
31  	public AddInterfaceActionFromURL() 
32     {
33        super( "Add WSDL from URL", "Adds all interfaces in a specified WSDL URL to the current project" );
34     }
35  	
36     public void perform( WsdlProject project, Object param )
37  	{
38        String url = UISupport.prompt( "Enter WSDL URL", "Add WSDL from URL", "" );
39        if( url == null ) return;
40        
41  		try
42  		{
43  			Boolean createRequests = UISupport.confirmOrCancel( "Create default requests for all operations", "Import WSDL" );
44  			if( createRequests == null )
45  				return;
46  			
47  			Interface[] ifaces = WsdlInterfaceFactory.importWsdl( project,url, createRequests);
48  			if (ifaces != null && ifaces.length > 0)
49  				UISupport.select(ifaces[0]);
50  		}
51  		catch (Exception ex)
52  		{
53  			UISupport.showErrorMessage( ex.getMessage() + ":" + ex.getCause() );
54  		}      
55     }
56  }