Announcement

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

    WSDL callOperation newbe problem

    Hi,
    Sorry if I am missing something obvious but as a SmartGWT and WSDL beginer I am facing the wall right now.

    This is simple wsdl I generated:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="http://axis/tech/com/pl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://axis/tech/com/pl/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://axis/tech/com/pl/">
        <wsdl:types>
            <xs:schema xmlns:ns="http://axis/tech/com/pl/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://axis/tech/com/pl/xsd">
                <xs:element name="hello">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="helloResponse">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:schema>
        </wsdl:types>
        <wsdl:message name="helloRequest">
            <wsdl:part name="parameters" element="ns0:hello"/>
        </wsdl:message>
        <wsdl:message name="helloResponse">
            <wsdl:part name="parameters" element="ns0:helloResponse"/>
        </wsdl:message>
        <wsdl:portType name="NewAxisFromJavaPortType">
            <wsdl:operation name="hello">
                <wsdl:input message="axis2:helloRequest" wsaw:Action="urn:hello"/>
                <wsdl:output message="axis2:helloResponse" wsaw:Action="urn:helloResponse"/>
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="NewAxisFromJavaSOAP11Binding" type="axis2:NewAxisFromJavaPortType">
            <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
            <wsdl:operation name="hello">
                <soap:operation soapAction="urn:hello" style="document"/>
                <wsdl:input>
                    <soap:body use="literal"/>
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="literal"/>
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:binding name="NewAxisFromJavaSOAP12Binding" type="axis2:NewAxisFromJavaPortType">
            <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
            <wsdl:operation name="hello">
                <soap12:operation soapAction="urn:hello" style="document"/>
                <wsdl:input>
                    <soap12:body use="literal"/>
                </wsdl:input>
                <wsdl:output>
                    <soap12:body use="literal"/>
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:binding name="NewAxisFromJavaHttpBinding" type="axis2:NewAxisFromJavaPortType">
            <http:binding verb="POST"/>
            <wsdl:operation name="hello">
                <http:operation location="NewAxisFromJava/hello"/>
                <wsdl:input>
                    <mime:content type="text/xml" part="hello"/>
                </wsdl:input>
                <wsdl:output>
                    <mime:content type="text/xml" part="hello"/>
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="NewAxisFromJava">
            <wsdl:port name="NewAxisFromJavaSOAP11port_http" binding="axis2:NewAxisFromJavaSOAP11Binding">
                <soap:address location="http://localhost:8080/axis2/services/NewAxisFromJava"/>
            </wsdl:port>
            <wsdl:port name="NewAxisFromJavaSOAP12port_http" binding="axis2:NewAxisFromJavaSOAP12Binding">
                <soap12:address location="http://localhost:8080/axis2/services/NewAxisFromJava"/>
            </wsdl:port>
            <wsdl:port name="NewAxisFromJavaHttpport" binding="axis2:NewAxisFromJavaHttpBinding">
                <http:address location="http://localhost:8080/axis2/services/NewAxisFromJava"/>
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>
    Service request sample is:
    Code:
       <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:ns0="http://axis/tech/com/pl/xsd"> 
     
       <ns0:hello> 
     
        <ns0:name>textValue</ns0:name>
    Service response sample is:
    Code:
       <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
     
       <soapenv:Body> 
     
       <ns:helloResponse xmlns:ns="http://axis/tech/com/pl/xsd"> 
     
        <ns:return>Hello tescik</ns:return>
    Finaly my java code:
    Code:
    package org.yournamehere.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.WSDLLoadCallback;
    import com.smartgwt.client.data.WebService;
    import com.smartgwt.client.data.WebServiceCallback;
    import com.smartgwt.client.data.XMLTools;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.StaticTextItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
    import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
    import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
    import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
    
    import com.smartgwt.client.widgets.layout.VLayout;
    import java.util.LinkedHashMap;
    import java.util.Map;
    
    
    public class MainEntryPoint implements EntryPoint {
    
        private WebService service;
    
        public void onModuleLoad() {
            VLayout layout = new VLayout(15);
            layout.setAutoHeight();
    
            final Form form = new Form();
            form.setLeft(50);
            form.setTop(50);
            form.setNumCols(3);
            form.setCellSpacing(5);
    
            TextItem field = new TextItem();
            field.setName("Test");
            field.addKeyPressHandler(new KeyPressHandler() {
                public void onKeyPress(KeyPressEvent event) {
                    if(event.getKeyName().equals("Enter")) {
                        form.callService();
                    }
                }
            });
    
            ButtonItem findButton = new ButtonItem("find", "Find");
            findButton.setStartRow(false);
            findButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    form.callService();
                }
            });
    
            StaticTextItem answer = new StaticTextItem();
            answer.setName("Answer");
            form.setItems(field, findButton, answer);
    
            layout.addMember(form);
    
            XMLTools.loadWSDL("/axis2/services/NewAxisFromJava.wsdl", new WSDLLoadCallback() {
                public void execute(WebService webService) {
                    service = webService;
                }
            });
    
            layout.draw();
            return;
        }
    
        class Form extends DynamicForm {
             public void callService() {
                 if(service == null) {
                     SC.say("Please try again in a moment  - still loading web service descriptor");
                 } else {
                     setValue("Answer", "Working...");
                     Map data = new LinkedHashMap();
                     data.put("name", getValueAsString("Test"));
                     service.callOperation("hello", data, null, new WebServiceCallback() {
                         public void execute(String[] data) {
                             System.out.println("!");
                             Form.this.setValue("Answer", data[0]);
                         }
                     });
                 }
            }
        }
    }
    service.callOperation callback routine is never executed - no errors or other messages on the debug console.

    Thanks for any help
    MichalG

    #2
    Could you clarify what step the code is currently reaching - do you see your server being contacted, do you see a valid response from the server in the RPC tab? Do you see any JS errors and does the same thing happen regardless of browser?

    Comment


      #3
      Originally posted by Isomorphic
      Could you clarify what step the code is currently reaching - do you see your server being contacted, do you see a valid response from the server in the RPC tab? Do you see any JS errors and does the same thing happen regardless of browser?
      Thank you for your time. I would try to clarify:
      1) The code is reaching this line:
      Code:
                       service.callOperation("hello", data, null, new WebServiceCallback() {
                           @Override
                           public void execute(String[] data) {
                               System.out.println("!");
                               Form.this.setValue("Answer", data[0]);
                           }
                       });
      and goes on, but Callback is not executed.

      2) Server is contacted - this is taken from Developer Console RPC tab:
      Code:
      0	/HelloGWT/js/sc/system/schema/schemaTranslator.xsl RPCRequest SUCCESS 10:21:40.156 812ms
      
      1	/axis2/services/NewAxisFromJava.wsdl RPCRequest SUCCESS 10:21:41.062 219ms
      
      2	http://localhost:8080/axis2/services/NewAxisFromJava RPCRequest SUCCESS 10:23:30.765 188ms
      3) The following can be seen on the Developer Console Results tab (log messages):
      Code:
      10:20:51.921:INFO:Log:initialized
      10:20:53.406:INFO:Log:isc.Page is loaded
      10:21:40.187:WARN:VLayout:isc_OID_0:ignoring bad or negative height: auto [enable 'sizing' log for stack trace]
      10:23:31.046:XRP6:WARN:Log:Error:
      	'Object doesn't support this property or method.'
      	in http://localhost:8080/HelloGWT/
      	at line 707
          WebService.$38w(_1=>[XMLDoc <soapenv:Envelope>], _2=>"<?xml version='1.0' encoding='UTF-8'?><s..."[270], _3=>Obj, _4=>Obj)
          Class.fireCallback(_1=>Obj, _2=>"xmlDoc,xmlText,rpcResponse,rpcRequest", _3=>Array[4], _4=>undef, _5=>undef) on [Class XMLTools]
          XMLTools.$37c(_1=>Obj, _2=>"<?xml version='1.0' encoding='UTF-8'?><s..."[270], _3=>Obj)
          ** recursed on Class.fireCallback
      All above in debug (hosted) mode.

      4) 'Object doesn't support this property or method.' occures as JS error then deploying on IE7.
      MichalG

      Comment


        #4
        Thanks for the extra info. Can you post the actual response? What you posted before was mangled (invalid XML missing end tags).

        Also, I think Firebug would give a different and perhaps better error report - what's the error message there?

        Comment


          #5
          Firefox Browser's JavaScript Console reports an error:
          Code:
          _7.contains is not a function
          http://localhost:8080/HelloGWT/js/sc/modules/ISC_DataBinding.js
          in line 706
          Code:
          _7.callback={target:this,methodName:"$38w"};isc.xml.getXMLResponse(_7)},$38w:function(_1,_2,_3,_4){var _5=_4.clientContext,_6=_5.$38s,_7=_5.$38u;_1.addNamespaces(this.getOutputNamespaces(_6));var _8=_7!=null&&_7.contains("/"),_9=(_8?_7:null),_10;if(_8){_10=_1.selectNodes(_9)}else if(_7){_10=this.selectByType(_1,_6,_7)}else{_10=_1.selectNodes("//s:Body/*",{s:"http://schemas.xmlsoap.org/soap/envelope/"});if(_10.length==1)_10=_10[0]}
          if(_5.$38v){this.fireCallback(_5.$38r,"data,xmlDoc,rpcResponse,wsRequest",[_10,_1,_3,_4]);return}
          var _11;if(_8){_11=null}else if(_7){_11=this.getSchema(_5.$38u)}else{var _12=this.getSchema("message:"+this.getOperation(_6).outputMessage);if(this.getSoapStyle(_6)!="document"){_11=_12}else{var _13=_12.getFieldNames().first();_11=_12.getSchema(_12.getField(_13).type)}}
          Response while testing service in browser:
          http://localhost:8080/axis2/services/NewAxisFromJava/hello?name=XYZ
          Code:
          - <ns:helloResponse xmlns:ns="http://axis/tech/com/pl/xsd">
            <ns:return>Hello XYZ</ns:return> 
            </ns:helloResponse>
          MichalG

          Comment


            #6
            Hmm, from code inspection, that looks impossible, eg, the relevant line reads:

            Code:
            var passedXPath = resultType != null && resultType.contains("/"),
            We'll see if this error can be reproduced with your WSDL, but you can almost certainly solve this by passing the resultType parameter to callOperation, and it seems like you'd want to do this anyway. It looks like you want to pass either "helloResponse" or "return".

            Comment


              #7
              Thanks.
              Well, I did pass resultType "helloResponse" and "return" like this:
              Code:
                               service.callOperation("hello", data, "return", new WebServiceCallback() {
                                   @Override
                                   public void execute(String[] data) {
                                       System.out.println("!");
                                       Form.this.setValue("Answer", data[0]);
                                   }
                               });
              and got the same JS error:
              In hosted mode on console
              Code:
              10:17:46.703:XRP1:WARN:Log:Error:
              	'Obiekt nie obsługuje tej właściwości lub metody.'
              	in http://localhost:8080/HelloGWT/
              	at line 707
                  WebService.$38w(_1=>[XMLDoc <soapenv:Envelope>], _2=>"<?xml version='1.0' encoding='UTF-8'?><s..."[270], _3=>Obj, _4=>Obj)
                  Class.fireCallback(_1=>Obj, _2=>"xmlDoc,xmlText,rpcResponse,rpcRequest", _3=>Array[4], _4=>undef, _5=>undef) on [Class XMLTools]
                  XMLTools.$37c(_1=>Obj, _2=>"<?xml version='1.0' encoding='UTF-8'?><s..."[270], _3=>Obj)
                  ** recursed on Class.fireCallback
              on IE7:
              Code:
              Row: 707
              Position: 193
              Error: Obiekt nie obsługuje tej właściwości lub metody.
              Code: 0
              and on Mozilla (line 706):
              Code:
              _7.contains is not a function
              http://localhost:8080/HelloGWT/js/sc/modules/ISC_DataBinding.js
              MichalG
              ps
              'Obiekt nie obsługuje tej właściwości lub metody.' means 'Object doesn't support this property or method.'

              Comment


                #8
                Well, this is quite odd. The crash you're reporting continues to appear impossible by code inspection, nothing has changed in this code recently, and callOperation is working everywhere else. Give us a couple of days and we'll attempt to reproduce the issue with your WSDL file.

                Comment


                  #9
                  There was an issue in the SmartGWT callOperation API. (wasn't passing resultType). The fix is in SVN. Can you try building from SVN and rerunning your sample?

                  Thanks,
                  Sanjiv

                  Comment


                    #10
                    With smartgwt.jar build from SVN I got:
                    - console hosted mode
                    Code:
                    11:20:56.656:XRP3:WARN:Log:Error:
                    	''ID' jest pusty lub nie jest obiektem'
                    	in http://localhost:8080/HelloGWT/
                    	at line 733
                        WebService.selectByType(_1=>[XMLDoc <soapenv:Envelope>], _2=>"hello", _3=>"return")
                        WebService.$38w(_1=>[XMLDoc <soapenv:Envelope>], _2=>"<?xml version='1.0' encoding='UTF-8'?><s..."[270], _3=>Obj, _4=>Obj)
                        Class.fireCallback(_1=>Obj, _2=>"xmlDoc,xmlText,rpcResponse,rpcRequest", _3=>Array[4], _4=>undef, _5=>undef) on [Class XMLTools]
                        XMLTools.$37c(_1=>Obj, _2=>"<?xml version='1.0' encoding='UTF-8'?><s..."[270], _3=>Obj)
                        ** recursed on Class.fireCallback
                    - IE7 JS: error in line 733 ''ID' jest pusty lub nie jest obiektem'
                    - Mozilla error console: _6 is null in row 732
                    Error: _6 is null
                    Source file: http://localhost:8080/HelloGWT/sc/modules/ISC_DataBinding.js
                    Row: 732
                    Code:
                    return _5},getInputHeaderSchema:function(_1){return this.getHeaderSchema(_1,true)},getOutputHeaderSchema:function(_1){return this.getHeaderSchema(_1,false)},getHeaderData:function(_1){},selectByType:function(_1,_2,_3){var _4=this.getOperation(_2),_5=this.getSchema("message:"+_4.outputMessage),_6=this.getSchema(_3);var _7=_5.findTagOfType(_6.ID),_8=_7[0],_9=_7[1],_10=_7[2],_11=_7[3],_12=_8.getField(_9);_9=_9||_6.ID;var _13=_6.mustQualify,_14=_6.schemaNamespace,_15="//"+(_13?"ns0:":"")+_9;if(_12&&_12.multiple)_15=_15+"/*";var _16=isc.xml.selectNodes(_1,_15,{ns0:_14});if(this.logIsDebugEnabled("xmlBinding")){this.logDebug("selecting type: '"+_6+"' within message '"+_4.outputMessage+" via XPath: "+_15+(_13?" using ns0: "+_6.schemaNamespace:"")+" got "+_16.length+" elements","xmlBinding")}
                    ''ID' jest pusty lub nie jest obiektem' means
                    'ID is empty or is not an object'

                    WSDL I am testing is created exactly following this tutorial:
                    http://www.netbeans.org/kb/docs/websvc/gs-axis.html

                    Thank you
                    MichalG

                    Comment


                      #11
                      See the docs for the resultType parameter - it should be a complex type or complex element, and "return" is not. However "helloResponse" is.

                      Comment


                        #12
                        OK, but when passing resultType="helloResponse":
                        Code:
                        Uncaught JavaScript exception [java.lang.ClassCastException: com.google.gwt.core.client.JavaScriptObject$ cannot be cast to java.lang.String
                                at com.smartgwt.client.util.JSOHelper.getArrayValue(JSOHelper.java)
                                at com.smartgwt.client.util.JSOHelper.convertToJavaStringArray(JSOHelper.java:556)
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:597)
                                at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                                at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
                                at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
                                at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
                                at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
                                at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
                                at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
                                at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
                                at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
                                at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
                                at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
                                at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)] in http://localhost:8080/HelloGWT/hosted.html?org_yournamehere_Main, line 5

                        Comment


                          #13
                          I'll try running your sample locally to see whats going on.

                          Sanjiv

                          Comment


                            #14
                            Can you try updating and building from SVN? I haven't had a chance to reproduce and verify your sample but I checked in a change that should help resolve your issue.

                            Let us know how it goes..

                            Thanks,
                            Sanjiv

                            Comment


                              #15
                              I have checked out v213 from SVN. Although thre are no JS errors now, the execute() method is never fired:
                              Code:
                                  class Form extends DynamicForm {
                                       public void callService() {
                                           if(service == null) {
                                               SC.say("Please try again in a moment  - still loading web service descriptor");
                                           } else {
                                               setValue("Answer", "Working...");
                                               Map data = new LinkedHashMap();
                                               data.put("name", getValueAsString("Test"));
                                               service.callOperation("hello", data, "helloResponse", new WebServiceCallback() {
                                                   public void execute(String[] data) {
                                                       System.out.println("!");
                                                       Form.this.setValue("Answer", data[0]);
                                                   }
                                               });
                                               System.out.println("data="+data);
                                           }
                                      }
                              Neither "Answer" widget is updated and System.out.println("!") printed on the console.
                              MichalG

                              Comment

                              Working...
                              X