views:

31

answers:

1

Hi All,

I am trying to access getListItems method of the Lists service of Sharepoint from Flex using WebService.

It is working fine when I omit the query and the viewFields nodes in the request xml. But if I add any query or FieldRef in Viewfields it is throwing error from the service.

Below is the code.

<mx:WebService id="ws2" wsdl="{url}/_vti_bin/Lists.asmx?WSDL"  result="ws2result(event)" fault="ws2fault(event)"  showBusyCursor="true">    
        <mx:operation name="GetListItems" resultFormat="e4x">
            <mx:request xmlns="http://schemas.microsoft.com/sharepoint/soap/"&gt;
                <listName>{listId}</listName>
                <viewName>{viewId}</viewName>
                <ViewFields><FieldRef Name='Locations'/></ViewFields>
            </mx:request>
        </mx:operation>
    </mx:WebService>

It is working fine without the ViewFields.

Can we use the ViewFields and query from flex?

Also is there any way to get the sum of items satisfying a specific condetions using this service?


Applied the new format. But still its throwing error.

The SOAP message captured from fiddler.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;  
    <SOAP-ENV:Body>  
    <tns:GetListItems xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/"&gt;  <tns:listName>{0A1C8CDA-E738-46B7-923D-1D2C599D960F}</tns:listName>  
    <tns:viewFields>  
    <tns:Name>ID</tns:Name>  
    </tns:viewFields>  
    </tns:GetListItems>  
    </SOAP-ENV:Body> 
    </SOAP-ENV:Envelope>

But the message in the operation tag is passed as below.

<mx:operation name="GetListItems" >
            <mx:request xmlns="http://schemas.microsoft.com/sharepoint/soap/"&gt;
                <listName>\{0A3C3DCA-E744-46C7-916D-1D2C539A960F\}</listName>
        <viewFields>
            <ViewFields>
                <FieldRef Name="ID" />
            </ViewFields>
        </viewFields>
    </mx:request>
</mx:operation>
+1  A: 

I can't tell for sure without seeing a sample of the actual SOAP message going over the wire, but I believe you're missing some containing elements in the request.

For your query, it needs to be structured as:

<query>
  <Query>
    <{CAML QUERY HERE}>
  </Query>
</query>

Note the case of the containing <query>. Same song, different verse for ViewFields:

<viewFields>
  <ViewFields>
    <FieldRef Name="foo" />
  </ViewFields>
</viewFields>

QueryOptions must also be contained in a <queryOptions> element. Crazy SharePoint!

CBono
Thank you CBono.I tried the new format. Still it is giving error. I checked the SOAP message with fiddler. It shows some difference from the actual format. I havee edited the question to add the current SOAP message.I think flex does some auto formatting on the message. Is this the issue? Is there any way to avoid the auto formatting?
Manoj M