Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #31
    Good to hear..

    Not afraid of the JavaScript I see :) Should have mentioned that the latest nightly builds have the transformRequest API, so this should be possible with a pure Java override now.

    Comment


      #32
      I am working against the latest snapshot, and did see the override point. But, with a return type of Object in its method signature, didn't quite know what to do in Java....

      So, have a fully functional SOAP backed paginating ListGrid with server-side sorting, matching the WSDL against ListGrid protocol. Now time to power a DynamicForm.

      Comment


        #33
        Return type is XML as String (for RestDataSource) or JavaScriptObject. (the javadocs indicate this). In your case it would be JavaScriptObject which you can manipulate the way you currently are by using the utility methods in JSOHelper.

        Comment


          #34
          Originally posted by hansvw@aivolution.com
          Got it...can see where it is missing now: WSDataSource.js.
          Thank you.
          sortBy is being passed by WSDataSource in build 12-17-2008+ so you should be able to remove your custom code.

          Comment


            #35
            DataSource.xmlSerialize

            This is great. Also noticed the following in your release notes:
            - added DataSource.xmlSerialize(),
            - added DSResponse.getData()

            Does this in any way address the last post regarding the return type for WSDataSource for DynamicForms? Having to work with JavaScriptObject responses would mean a new round of adjusting the code generator I use for client / back-end plumbing, just after adjusting it from gwt-rpc to soap.

            Comment


              #36
              Not sure what your concern is there - the getData() API in SmartGWT was just wrong (returned Boolean) and is now corrected. The underlying SmartClient API you are using through JSNI won't be changing.

              Comment


                #37
                wsdl integration example

                Hans, can u post your code? as an example?

                thanks!

                Bas

                Comment


                  #38
                  sample code

                  Sorry it took me a while to get back to you on this. Here are code extracts relevant to WS powered data-grid I got running with the excellent help provided on this forum. Please note that since this came from a larger project, had to do some renaming without checking for errors...Hope it still ends up saving you some time.

                  1. entry point, key here was to load the WSDL before constructing the data-source backed grid UI. Not doing so results in the trouble that started this thread.
                  Code:
                  package a.b.c.smartgwt.soap;
                  
                  /// gwt / smartgwt imports
                  /// ...
                  
                  public class Application implements EntryPoint, HistoryListener 
                  {
                  	public void onModuleLoad()
                  	{
                  		/// ...
                                       String url = com.smartgwt.client.util.Page.getAppDir();
                  				
                  		     XMLTools.loadWSDL(
                  					url + "/services/SOAPDS?wsdl", 
                  					new WSDLLoadCallback()
                  					{
                  						public void execute(WebService webService)                               {
                  						/// create and display data-grid
                  						/// ...
                  						}
                  					}
                  				);
                  		/// ...
                  }
                  2. from WSDataSource derived data source:
                  Code:
                  /* ABCSOAPDataSource.java */
                  	package a.b.c.smartgwt.client.data;
                  
                  /// smartgwt imports	
                  	
                  	public class ABCSOAPDataSource extends WSDataSource
                  	{
                  	private static ABCSOAPDataSource instance = null;
                  	    
                  	public static ABCSOAPDataSource getInstance() 
                  	{
                  	    if (instance == null) 
                  	    {
                  	        instance = new ABCSOAPDataSource("abcsoap");
                  	        OperationBinding fetchBinding = new OperationBinding();
                  		fetchBinding.setOperationType(DSOperationType.FETCH);
                  		fetchBinding.setWsOperation("fetch");
                  		fetchBinding.setRecordXPath("//data/*");
                  		fetchBinding.setRecordName("elem");
                  
                  		instance.setOperationBindings(fetchBinding);
                  				
                  		DataSourceField idField = 
                  			new DataSourceField("id", FieldType.TEXT);
                  		DataSourceField ppnoField = 
                  			new DataSourceField("ppno", FieldType.TEXT);
                  
                                 /// many other fields ...
                  
                  		instance.setFields(idField, ppnoField, 
                                  /// many other fields ...);
                  					
                                  instance.setDataFormat(DSDataFormat.XML);
                  	    }
                  	        
                  	    return instance;
                  	}
                  
                  	protected ABCSOAPDataSource(String id)
                  	{
                  		super();
                  	        setID(id);
                  	        setServiceNamespace("urn:soap.server.smartclient.c.b.a");
                  	    }
                  	}
                      }
                  3. The data grid, in a tab-set context
                  Code:
                  	package a.b.c.smartgwt.client;
                  
                  	import a.b.c.smartgwt.client.data.ABCSOAPDataSource;
                  
                      /// other imports....
                  	
                  	public class DataTabSet extends Canvas implements IPageSubscriber
                  	{
                  		private	TabSet		     tabSet;
                  
                  		public DataTabSet()
                  		{
                  			super();
                  			
                  			tabSet = new TabSet();
                  			tabSet.setWidth100();
                  			tabSet.setHeight100();
                  			addChild(tabSet);
                  			
                  		/// ...
                  		}
                  		
                  		public void addABCDataGridTab()
                  		{
                  			tabSet.addTab(createABCDataGridTab());
                  		}
                  		
                  		private Tab createABCDataGridTab()
                  		{
                  			Tab tab = new Tab("ABC Data");
                  			
                  			VLayout tabLayout = new VLayout();
                  			tabLayout.setWidth100();
                  			tabLayout.setHeight100();
                  
                  			Canvas gridPanel = createABCGridPanel(); 
                  			gridPanel.setWidth100();
                  			gridPanel.setHeight100();
                  			
                  			HLayout toolPanel = new HLayout();
                  			toolPanel.setWidth100();
                  			toolPanel.setHeight(40);
                  			
                  			tabLayout.addMember(gridPanel);
                  			tabLayout.addMember(toolPanel);
                  			
                  			tab.setPane(tabLayout);
                  			return tab;
                  		}
                  		
                  		public Canvas createABCGridPanel() 
                  		{
                  			ListGridField pk = new ListGridField("id");
                  			pk.setHidden(true);
                  			
                  			ListGridField ppno = new ListGridField("ppno",
                  				"PPNO", 100);
                  			ListGridField ea = new ListGridField("ea", 
                  				"EA", 100);
                  
                                          /// many other fields		     			
                  
                  		    final ListGrid listGrid = new ListGrid();
                  		    listGrid.setWidth100();
                  		    listGrid.setHeight100();
                  		    listGrid.setAutoFetchData(false);
                  		    listGrid.setCanGroupBy(true);
                  		    listGrid.setAlternateRecordStyles(true);
                  		    listGrid.setFields(	ppno, ea, 
                                 /// many other fields
                                      );
                  		    ppno.setCanGroupBy(true);
                  		    ppno.setCanSort(true);
                  		    
                  		    listGrid.setDataPageSize(100);
                  		    
                  		    final DataSource dataSource =  ABCSOAPDataSource.getInstance();
                  				listGrid.setDataSource(dataSource);
                  
                  				Criteria c = new Criteria();
                  				c.addCriteria("district", "D10");
                  			
                  				listGrid.fetchData(c);
                  		    
                  		    return listGrid;
                  		}
                  /// ...
                  	}
                  4. WSDL, essentially SmartClientOperations.wsdl with different URN
                  Code:
                  <!--SOAPDS.wsdl, essentially SmartClientOperations.wsdl with different urn --> 
                  <?xml version="1.0"?>
                  <definitions    name="SOAPDS" 
                                  targetNamespace="urn:soap.server.smartgwt.c.b.a"
                                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                                  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
                                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                                  xmlns:tns="urn:soap.server.smartgwt.c.b.a"
                                  xmlns:fns="urn:soap.server.smartgwt.c.b.a"
                                  xmlns="http://schemas.xmlsoap.org/wsdl/">
                  
                      <types>
                          <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" 
                              targetNamespace="urn:soap.server.smartgwt.c.b.a">
                         <!-- RPC response codes:  same as SmartClientOperations.wsdl-->
                  
                         <!-- DSRequest:  same as SmartClientOperations.wsdl-->
                  
                         <!-- DSResponse:  same as SmartClientOperations.wsdl-->
                  
                         <!-- same as SmartClientOperations.wsdl -->
                          </xsd:schema>
                      </types>
                  
                      <!--message names same as SmartClientOperations.wsdl-->
                  
                      <portType name="ABCSOAPPort">
                          <operation name="fetch">
                              <input message="tns:fetchRequest"/>
                              <output message="tns:fetchResponse"/>
                          </operation>
                          <operation name="add">
                              <input message="tns:addRequest"/>
                              <output message="tns:addResponse"/>
                          </operation>
                          <operation name="remove">
                              <input message="tns:removeRequest"/>
                              <output message="tns:removeResponse"/>
                          </operation>
                          <operation name="update">
                              <input message="tns:updateRequest"/>
                              <output message="tns:updateResponse"/>
                          </operation>
                      </portType>
                  
                  <!--multiop -->
                      <binding name="ABCSOAPBinding" type="tns:ABCSOAPPort">
                          <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
                          <operation name="fetch">
                              <soap:operation  soapAction="urn:soap.server.smargwt.c.b.a#fetch"/>
                              <input>
                                  <soap:body use="literal"/>
                              </input>
                              <output>
                                  <soap:body use="literal"/>
                              </output>
                          </operation>
                          <operation name="add">
                              <soap:operation soapAction="urn:soap.server.smargwt.c.b.a#add"/>
                              <input>
                                  <soap:body use="literal"/>
                              </input>
                              <output>
                                  <soap:body use="literal"/>
                              </output>
                          </operation>
                          <operation name="remove">
                              <soap:operation soapAction="urn:soap.server.smargwt.c.b.a#remove"/>
                              <input>
                                  <soap:body use="literal"/>
                              </input>
                              <output>
                                  <soap:body use="literal"/>
                              </output>
                          </operation>
                          <operation name="update">
                              <soap:operation soapAction="urn:soap.server.smargwt.c.b.a#update"/>
                              <input>
                                  <soap:body use="literal"/>
                              </input>
                              <output>
                                  <soap:body use="literal"/>
                              </output>
                          </operation>
                      </binding>
                  
                  <!--Soap Service Endpoint -->
                      <service name="SOAPDS">
                          <port name="SOAPDS" binding="tns:ABCSOAPBinding">
                              <soap:address location="/services/SOAPDS"/>
                          </port>
                      </service>
                  </definitions>
                  5. Ant build script targets to generate java from wsdl + deploy web-services to tomcat server:
                  Code:
                  <!-- build.xml -->
                  <!-- ... -->
                  	<!--Generation of Java code from WSDL-->
                  		<target name="wsdl.generate" depends="dependencies.prepare">
                  		<taskdef name="wsdl2java"
                  		classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask"
                  		classpath="${jar.axis-anttask}:${jar.axis}:${jar.axis-commons-discovery}:
                  		${jar.axis-commons-logging}:${jar.axis-jaxrpc}:${jar.axis-saaj}:${jar.axis-wsdl4j}"/>
                  		<wsdl2java allowinvalidurl="true" serverside="true"
                  				output="${dir.src.java}"
                  				url="${dir.src.wsdl}/SOAPDS.wsdl">
                  		</wsdl2java>		
                          </target>
                  	<!-- ... -->
                  
                  	<!--Deployment of Web-Service-->
                  		<target name="webservices.deploy">
                  			<taskdef name="axisadmin"		classname="org.apache.axis.tools.ant.axis.AdminClientTask"
                  	classpath="${jar.axis-anttask}:${jar.axis}:${jar.axis-commons-discovery}:${jar.axis-commons-logging}:${jar.axis-jaxrpc}:${jar.axis-saaj}:${jar.axis-wsdl4j}">
                  		        </taskdef>
                  			<axisadmin
                  				username="abcuser"
                  				password="abcpassword"
                  				<!-- deploy.wsdd generated by axis 1.4 ->
                  					url="http://localhost:8080/abc/servlet/AxisServlet"
                  				xmlfile="${dir.src.java}/a/b/c/smartgwt/server/soap/deploy.wsdd">
                  			</axisadmin>
                  			</target>
                  			<!--Deployment of Web-Service-->
                  			<target name="webservices.undeploy">
                  				<taskdef name="axisadmin"
                  					classname="org.apache.axis.tools.ant.axis.AdminClientTask"
                  					classpath="${jar.axis-anttask}:${jar.axis}:${jar.axis-commons-discovery}:
                  					${jar.axis-commons-logging}:${jar.axis-jaxrpc}:${jar.axis-saaj}:${jar.axis-wsdl4j}">
                  			</taskdef>
                  			<axisadmin
                  					username="abcuser"
                  					password="abcpassword"
                  					<!-- undeploy.wsdd generated by axis 1.4 ->
                  					url="http://localhost:8080/abc/servlet/AxisServlet"
                  							xmlfile="${dir.src.java}/a/b/c/smartgwt/server/soap/undeploy.wsdd">
                  			</axisadmin>
                  		</target>

                  Comment


                    #39
                    Awesome Hans, thanks for posting that!

                    Comment

                    Working...
                    X