Announcement

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

    Databind to a simple Axis2 service

    Hi there,

    I'm a newbie to SmartGWT and trying to get one of the example from showcase to work with my test web service hosted with Tomcat5 + Axis2. Browser is Firefox 18.0. The SmartGWT version is 3.1. Many thanks for all of you and any help would be very appreciated.

    Pass value 1 into the getTreeChildren method should return a list of TreeNode objects. I've done a unit test in .net and it works ok. In the developer console, I can see smartgwt managed to call the service and get response xml file back ok. However, it find 0 TreeNode elements (found 10 objects in .net test). I've attached the console log at the end of this thread.

    Also a warning has been displayed in the console as follows.
    17:10:04.775 [ERROR] [connectonline] 17:10:04.758:XRP2:WARN:Log:'undefined' is not a valid JavaScript identifier. DataSource and DataBoundComponent field names are required to be valid JavaScript identifiers, the syntax for which is specified by ECMA-262 Section 7.6. Note: The String.isValidID(string) function can be used to test whether a string is a valid identifier. This field applied to [XSElement ID:getTreeChildrenResponse]. This will be the last warning.

    I believe this might because there is name="return" field in my wsdl. The warning has gone away once I change the name to something else. However, the service seems been broken after I changed the name and I couldn't get objects in my .net unit test after I changed the wsdl.

    The testing service wsdl is http://interconnecttestcloud.net:8080/axis2/services/IRRIADataProvider?wsdl

    My source code is as follows.
    final Canvas canvas = new Canvas();
    canvas.setWidth100();
    canvas.setHeight100();
    final String wsdlURL = "http://interconnecttestcloud.net:8080/axis2/services/IRRIADataProvider?wsdl";
    final String namespaceURL = "http://ria.service.dataexchange.model.simplypos.co";
    SC.showPrompt("Loading WSDL from: " + wsdlURL);
    final String wsOperation = "getTreeChildren";

    XMLTools.loadWSDL(wsdlURL, new WSDLLoadCallback() {
    public void execute(WebService service) {
    if(service == null) {
    SC.warn("WSDL not currently available", new BooleanCallback() {
    public void execute(Boolean value) {
    }
    });
    return;
    }

    DataSource inputDS = service.getInputDS(wsOperation);

    XmlNamespaces ns = new XmlNamespaces();
    ns.addNamespace("ns", namespaceURL);



    DataSource resultDS = new DataSource();
    resultDS.setID("TreeChildren");
    resultDS.setServiceNamespace(namespaceURL);
    resultDS.setXmlNamespaces(ns);
    resultDS.setRecordName("TreeNode");


    OperationBinding opb = new OperationBinding(DSOperationType.FETCH, wsdlURL);
    opb.setXmlNamespaces(ns);
    opb.setWsOperation(wsOperation);
    opb.setRecordName("TreeNode");


    resultDS.setOperationBindings(opb);

    DataSourceField field=new DataSourceField("description", FieldType.TEXT);
    DataSourceField field2=new DataSourceField("vendorArticleId", FieldType.INTEGER);
    field2.setPrimaryKey(true);
    resultDS.setFields(field,field2);






    VLayout layout = new VLayout(20);
    layout.setWidth100();
    layout.setHeight100();
    layout.setLayoutMargin(40);

    final DynamicForm searchForm = new DynamicForm();
    searchForm.setNumCols(4);
    searchForm.setWidth(500);
    searchForm.setDataSource(inputDS);

    final ListGrid searchResults = new ListGrid();
    searchResults.setWidth100();
    searchResults.setDataSource(resultDS);

    IButton searchButton = new IButton("Search");
    searchButton.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
    searchResults.fetchData(searchForm.getValuesAsCriteria());
    }
    });

    layout.addMember(searchForm);
    layout.addMember(searchButton);
    layout.addMember(searchResults);
    canvas.addChild(layout);


    SC.clearPrompt();

    }
    });





    canvas.draw();




    And the console log is:
    17:42:26.234:INFO:Log:initialized
    17:42:26.532:WARN:Log:New Class ID: 'DataView' collides with ID of existing object with value 'function DataView() {
    [native code]
    }'. Existing object will be replaced.
    This conflict would be avoided by disabling ISC Simple Names mode. See documentation for further information.
    17:42:31.439:INFO:Log:isc.Page is loaded
    17:42:31.680:XRP3:WARN:Log:'return' is not a valid JavaScript identifier. DataSource and DataBoundComponent field names are required to be valid JavaScript identifiers, the syntax for which is specified by ECMA-262 Section 7.6. Note: The String.isValidID(string) function can be used to test whether a string is a valid identifier. This field applied to [XSElement ID:getTreeChildrenResponse]. This will be the last warning.
    Global Log Priorities updated: Logging messages at priority 'Debug' and above for category 'xmlBinding'.
    Global Log Priorities updated: Logging messages at priority 'Debug' and above for category 'ResultSet'.
    17:42:52.263:MUP3:INFO:ResultSet:isc_ListGrid_0:Creating new isc.ResultSet for operation 'TreeChildren_fetch' with filterValues: {
    "vendorArticleId":"1"
    }
    17:42:52.268:MUP3:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):setCriteria: filter criteria changed, invalidating cache
    17:42:52.268:MUP3:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Invalidating cache
    17:42:52.278:MUP3:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0,47), cache check: 0,60 firstMissingRow: 0 lastMissingRow: 60
    17:42:52.278:MUP3:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange: guessing forward scrolling
    17:42:52.278:MUP3:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 47) will fetch from 0 to 75
    17:42:52.278:MUP3:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):fetching rows 0,75 from server
    17:42:52.282:MUP3:INFO:xmlBinding:TreeChildren:web service: [WebService ns="http://ria.service.dataexchange.model.si..."[50] location=IRRIADataProvider?wsdl], wsOperation: Obj{name:getTreeChildren}
    17:42:52.286:MUP3:DEBUG:xmlBinding:TreeChildren:XML post requestBody is: <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header></soap:Header>
    <soap:Body
    xmlns:ns="http://ria.service.dataexchange.model.simplypos.co">

    <ns:getTreeChildren>
    <ns:vendorArticleId>1</ns:vendorArticleId>
    </ns:getTreeChildren>
    </soap:Body>
    </soap:Envelope>
    17:42:52.286:MUP3:DEBUG:xmlBinding:TreeChildren:serviceInputs are: {actionURL: "http://interconnecttestcloud.net:8080/ax..."[75],
    httpMethod: "POST",
    data: "<soap:Envelope xmlns:soap='http://schema..."[469],
    contentType: "text/xml",
    httpHeaders: Obj}
    17:42:52.305:TMR7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(0, 47) satisfied from cache
    17:42:52.835:XRP2:DEBUG:xmlBinding:selecting type: '[XSComplexType ID:TreeNode]' within message 'getTreeChildrenResponse via XPath: //ns0:return using ns0: http://ria.service.dataexchange.model.simplypos.co/xsd got 0 elements
    17:42:52.837:XRP2:INFO:xmlBinding:TreeChildren:dsResponse is: {data: Array[0],
    startRow: 0,
    status: 0,
    endRow: 0,
    totalRows: 0,
    httpResponseCode: 200,
    transactionNum: 2,
    clientContext: Obj,
    httpHeaders: Obj}
    17:42:52.839:XRP2:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Received 0 records from server
    17:42:52.839:XRP2:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):full length set to: 0
    17:42:52.839:XRP2:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):integrating 0 rows into cache at position 0
    17:42:52.839:XRP2:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):cached 0 rows, from 0 to 0 (0 total rows, 0 cached)
    17:42:52.839:XRP2:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Cache for current criteria complete

    #2
    First, a sanity check: if you don't have to use WSDL, don't. It's far more complicated than REST, slower, and more error prone.

    It looks like probably your namespace is wrong for your XPath, but you haven't posted the service's response, which would be needed to tell for sure.

    Comment


      #3
      Thanks for your reply and I'll bear your advice in mind when I start the project. We have a established Axis2 service running and would like try to reuse it if we can.

      Here is the service response. Many thanks for your kind help.

      <?xml version='1.0' encoding='UTF-8'?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
      <ns:getTreeChildrenResponse xmlns:ns="http://ria.service.dataexchange.model.simplypos.co" xmlns:ax21="http://ria.service.dataexchange.model.simplypos.co/xsd">
      <ns:return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:TreeNode">
      <ax21:description>Scarves</ax21:description>
      <ax21:vendorArticleId>11</ax21:vendorArticleId>
      </ns:return>
      ..More TreeNode elements...
      </ns:getTreeChildrenResponse>
      </soapenv:Body>
      </soapenv:Envelope>
      Last edited by yzhou@intelligentretail.co.uk; 17 Jan 2013, 03:23.

      Comment


        #4
        Isomorphic you're right. It's something to do with the namespace. I've added <schema elementFormDefaultQualified="false"/> into services.xml which removed the namespace from the description and vendorArticleId field. Then it start to work.

        But any idea what I should to change if I keep the wsdl as above without using the elementFormDefaultQualified="false" setting?

        Comment


          #5
          See this FAQ for an explanation of why you generally *don't* want to re-use existing services, because they are almost always inadequate.

          As far as what's going wrong, look at the log:

          Code:
          17:42:52.835:XRP2:DEBUG:xmlBinding:selecting type: '[XSComplexType ID:TreeNode]' within message 'getTreeChildrenResponse via XPath: //ns0:return using ns0: http://ria.service.dataexchange.model.simplypos.co/xsd got 0 elements
          The namespace you are using to select the element is not the same as the one used in the document to qualify the element (the namespace used for the select has "/xsd" added at the end).

          Comment


            #6
            Originally posted by Isomorphic View Post
            See this FAQ for an explanation of why you generally *don't* want to re-use existing services, because they are almost always inadequate.

            As far as what's going wrong, look at the log:

            Code:
            17:42:52.835:XRP2:DEBUG:xmlBinding:selecting type: '[XSComplexType ID:TreeNode]' within message 'getTreeChildrenResponse via XPath: //ns0:return using ns0: http://ria.service.dataexchange.model.simplypos.co/xsd got 0 elements
            The namespace you are using to select the element is not the same as the one used in the document to qualify the element (the namespace used for the select has "/xsd" added at the end).
            Thanks Isomorphic,

            Have ready through the FAQ and it makes perfect sense to me now. Definitely good to know this before we start the project.

            Thanks for pointing out the log for me. I've noticed it and did try to put the /xsd namespace in before. Probably something other part of code not right and I didn't manage to get it work. But now your reply and my test confirmed the problem and I'll give it another go.

            Many thanks for your help!

            Comment

            Working...
            X