12 Replies Latest reply on Dec 1, 2009 10:42 PM by SrinivasAnnam

    Help with SharePoint Web Services


      I am new to Flash Builder, but am interested in learning how to develop an application that can integrate with SharePoint web services.  I have used the Web Services import tool to generate the appropriate definitions for the relevant classes and methods (I followed this tutorial).  However, when I try to bind one of these web services to a control--like a data grid--I cannot seem to get at the response received from the Web Service call.


      For example, let's say I drag-n-drop a data grid to the canvas, and then drag-n-drop one of the web service calls (example: GetList) generated from the WSDL import.  A function is automatically created on the creationComplete for the Data Grid which does the following:


      private function goAndGetTheList(event:FlexEvent):void {

           GetListResult.token = SPListService.GetList('xxx-xxx-xx-xxx-xxx');



              <s:CallResponder id="GetListResult"/>
              <splistservice:SPListService id="SPListService" fault="Alert.show(event.fault.faultString)" showBusyCursor="true"/>


      And of course, my DataGrid dataProvider is set to GetListResult.lastResult


      When I run this application, however, I don't receive the expected results, at least not in the Data Grid.  When I debug the GetListResult.lastResult, it appears that the appropriate structure is returned.  And when I view the actual response from the Web Service call, I can plainly see that the XML returned from SharePoint contains the expected information.


      I guess my question is what step am I missing?  If the Web Service call brings back the right information, how do I translate it to the Data Grid? I have read about perhaps needing to configure the return type, but I do not seem to be able to do this--at least not as the tutorial I am following suggests to do it.


      Again, I am new to this, so it is quite possible that I am missing something ridiculously simple and basic.  However, I am having trouble Googling a solution because I don't feel that I have a sufficient conceptual framework to even begin to ask the right questions.  I don't mind doing the work the learn this, but I need some idea of where to start.


      I appreciate any help that you can provide, especially if you have the time to "fill in" some of the gaps in my knowledge, or at least point me in the right direction.



        • 1. Re: Help with SharePoint Web Services
          SrinivasAnnam Adobe Employee



             Could you please attach the MXML file and FML file to this thread so that we can have a look and debug the issue.


             FML file will be inside ".model" folder of your project directory.



          Srinivas Annam


          • 2. Re: Help with SharePoint Web Services
            existdissolve Level 2

            Hi Srinivas--


            Thanks for the quick response!  I'm away from my computer, but I will post what I have once I am back home.  Thanks again for your willingness to look at this!



            • 3. Re: Help with SharePoint Web Services
              existdissolve Level 2

              Hi Srinivas--


              I'm attaching the files you requested.  In briefly looking at the .fml file, I notice that function arguments do not match those expected by the web service method GetListItems (per msdn), nor does the return type.  I suspect this might have something to do with what's going on, but I'm also at a loss as to what would need to be done to resolve this.


              Any help you can provide would be greatly appreciated--thanks!!!

              • 4. Re: Help with SharePoint Web Services
                SrinivasAnnam Adobe Employee



                   Thanks a lot for sending the FML file & MXML file. That gave us good insight in to your problem.


                   1. When I tried with an internal SharePoint WebService, input arguments were introspected properly and I got 7 input arguments for this operation. But, I see only four arguments in your FML file. And even the argument names are different from what is mentioned in MSDN & what I got. You can also once try with a new project with single service and you could also save and send me a copy of the Lists.asmx WSDL file to have a look at it.


                    2. Return type is shown as "Object" for some operations. This is because the WSDL file specifies the return type of the Operation to be "any". This can be solved once we enable "Configure Return Type" feature for WebServices.


                   3. Using "Object" as "resultFormat" for WebService operations don't work. You need to explicitly set it as "e4x" or "xml". I have logged this bug for this issue http://bugs.adobe.com/jira/browse/SDK-23140


                      DCD workflows set this to "Object" by default and does not allow users to customize at this point. So, I'm providing a quick dirty workaround for this.


                      Here is the workaround, every DCD service will generate "<ServiceName>.as" file in specified package. So, we can add a constructor to this class and loop through all the operations to set the result format to "e4x". We can also add a result handler to properly decode the result. You can look at the attached sample to get a clear idea.


                      "Lists" is the service name in attached sample. The service class is automatically generated by FlashBuilder for you and can be found under "services.<service_name>" package. I added a consturctor & result handler inside this class. You can similarly add these two methods for all WebService classes in your project to get it working.


                     Feel free to contact me if you have any issues or clarifications.



                Srinivas Annam


                • 5. Re: Help with SharePoint Web Services
                  SrinivasAnnam Adobe Employee

                  Attachments did not come through. Trying once again.

                  • 6. Re: Help with SharePoint Web Services
                    existdissolve Level 2



                    This works great!  Thank you very much for your help with this.


                    There is one thing, however, that is a bit strange.  No matter what I do, Flash Builder does not seem to introspect the Lists wsdl properly.  I've created new projects, tried it with several different environments, but the import still returns 4 arguments instead of 7 for the GetListItems method.  If I manually update the _Super_Lists.as to match the correct number of arguments and implement the code you provided, it seems to work correctly.  However, it just does not seem to want to import correctly (or I'm doing something wrong...more likely ).


                    I'm attaching the lists.asmx file if you'd like to take a look.


                    Again, I very much appreciate all of your help on this!

                    • 7. Re: Help with SharePoint Web Services
                      existdissolve Level 2

                      Sorry, one more question


                      My SharePoint instance requires authentication, and currently it's running in Windows Authentication mode.  Is there a way for Flash Builder to pass the authenicated Windows user's credentials along with (or in advance of) the web service requests?  Right now the requests I make succeed, but I do have to authenticate my user with each request.



                      • 8. Re: Help with SharePoint Web Services
                        SrinivasAnnam Adobe Employee



                            Nice to know that you are able to proceed with this workaround.


                            I just imported your WSDL on Beta 1 build and I too got only 4 parameters. So, this looks like a bug in Beta 1 build which already got fixed in the latest build.


                           You could try on the latest Pre-Releast build (if you have access) or you should wait for the next public Beta of Gumbo.


                            Coming to authentiction, There is no inbuilt support provided Flash/Flex for Windows Authentication mode. There is a bug already logged for this https://bugs.adobe.com/jira/browse/SDK-14554. Here is an external solution which you can try. http://www.svendens.com/flex/soap-headers-in-flex-and-ws-security/


                            One more option is to switch your authentication mode to Basic Authentication in your IIS settings for this folder.


                            However, Its not recommended to embed username & password inside your SWF file because it can extracted by decompiling. So, I feel its better to leave the authentication mechanism to browser.



                        Srinivas Annam

                        • 9. Re: Help with SharePoint Web Services
                          ajdove Level 1

                          I am having difficulty implementing your solution. I am using Flex Builder 3 and SharePoint MOSS 2007. Do you have a solution for integrating Flex as a front-end to enable read/write capabilities to SharePoint? I visitied your wordpress website but could not find any contact information.



                          • 10. Re: Help with SharePoint Web Services
                            SrinivasAnnam Adobe Employee

                            Hi Alex,


                               The above mentioned solution is for Flash Builder 4 through new "Data Centric Development" features.


                               Can you please exactly tell me the issue that you are facing in Flex 3 so that I can give you the right solution.



                            Srinivas Annam


                            • 11. Re: Help with SharePoint Web Services
                              ajdove Level 1

                              Ok, I am currently receiving a security error locating my WSDL file when trying to run a Flex 3 app connected to a .Net web service. Here are the particulars of my problem:


                              I have been working on a solution which appears like it would work fine. The source code and examples are found on Code Project http://www.codeproject.com/KB/aspnet/FlexASPWebService.aspx?msg=3270246#xx3270246xx This Flex/ASP example uses a web service to communicate to a SQL database.  Flex makes a web service call to the .asmx file via WSDL and the magic happens. I am running into a roadblock as I receive an error that the app cannot find the WSDL.  I have tried to run the same WSDL URL in a browser and I get an server application error.


                              I also tried a solution found at http://shardulbartwal.wordpress.com/2008/03/20/import-web-servicewsdl-wizard-in-flex-30/ to load the WSDL file directly into Flex, but I ran into another roadblock.  When I get to this step I receive the same error that it cannot find the WSDL file either...




                              Here is the WebService call from Flex…

                              <mx:WebService id="ws" wsdl="http://localhost/TestWebService/Service.asmx?WSDL" fault="fault(event)">


                              The Code for the Flex file is as follows…


                              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">




                                          import mx.controls.Alert;

                                          import mx.rpc.events.FaultEvent;

                                          import mx.rpc.events.ResultEvent;


                                          private function init():void {

                                                // Get Data from WebService and fill datagrid when you fist invoke the application




                                          private function GetEmployees(event:ResultEvent):void {

                                                // Databind data from webservice to datagrid

                                                datagrid.dataProvider = event.result;


                                          private function SaveEmployee(event:ResultEvent):void {

                                                // To Refresh DataGrid;


                                                Alert.show("Saved Successfully");


                                          private function AddRecord(event:MouseEvent):void {

                                                // Save a record using a WebService method

                                                ws.SaveEmployee(txtEmpId.text, txtEmpName.text, txtEmpEmail.text); //


                                          private function fault(event:FaultEvent):void {

                                                // Oppps some error occured








                              <!-- WebService definition -->

                              <mx:WebService id="ws" wsdl="http://localhost/TestWebService/Service.asmx?WSDL" fault="fault(event)">












                                    <mx:Panel x="41.5" y="66" width="714.5" height="237" layout="absolute" title="ASP.NET WebService + Flex Demonstration">

                                          <mx:HBox height="95%" width="95%" horizontalCenter="0" verticalCenter="0">

                                                <mx:DataGrid id="datagrid" width="465" height="100%">


                                                            <mx:DataGridColumn headerText="Emp Id" dataField="EmpId"/>

                                                            <mx:DataGridColumn headerText="Emp Name" dataField="EmpName"/>

                                                            <mx:DataGridColumn headerText="Emp Email" dataField="EmpEmail"/>



                                                <mx:Form x="608" y="74" width="100%" height="100%" borderStyle="solid">

                                                      <mx:FormItem label="EmpId">

                                                            <mx:TextInput width="106" id="txtEmpId"/>


                                                      <mx:FormItem label="EmpName">

                                                            <mx:TextInput width="106" id="txtEmpName"/>


                                                      <mx:FormItem label="EmpEmail">

                                                            <mx:TextInput width="106" id="txtEmpEmail"/>


                                                      <mx:FormItem width="156" horizontalAlign="right">

                                                            <mx:Button label="Add" id="btnAdd" click="AddRecord(event)"/>








                              The Service.cs file is inside the App_Code directory and is referenced from the Service.asmx file with this code:


                              <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="Service" %>


                              I don’t know what I am doing wrong...

                              • 12. Re: Help with SharePoint Web Services
                                SrinivasAnnam Adobe Employee



                                    This looks like a security error to me. Could you please try deploying the attached "crossdomain.xml" on the web root of your localhost server and try invoking the Flex client again.


                                    Let us know if this works for you.



                                Srinivas Annam