insert new item in sharepoint list from flex - apache-flex

i m trying to insert new item on sharepoint list from flex using sharepoint-as3-connector (http://code.google.com/p/sharepoint-as3-connector). but i m getting following error.
Response XML:<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:Body>
<UpdateListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<UpdateListItemsResult>
<Results>
<Result ID="1,UpdateList.NEW">
<ErrorCode>0x8102000a</ErrorCode>
<ErrorText>Invalid URL Parameter
The URL provided contains an invalid Command or Value. Please check the URL again.
below is the header made in soap URL.
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>
TestList
</listName>
<updates>
<Batch OnError="Continue">
<Method ID="1" Cmd="UpdateList.NEW">
<Field Name="ows_LinkTitle">
222222
</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
please help!

The error message is spot on: you are specifying an invalid command in the Cmd attribute of the Method element.
Per the MSDN article for the Method element, valid values for Cmd are:
Delete
New
Update
I have no experience with the "sharepoint-as3-connector", and I suppose it's there to make your life easier. But it's probably worth reviewing the MSDN documentation for the Lists web service (and specifically the UpdateListItems method) so you know what SharePoint is expecting. SharePoint is a delicate flower that cannot be handled harshly; you must know exactly what it wants to keep it happy.
A good walkthrough on MSDN: How to: Update List Items.

Related

Redirecting to xml with query string in asp.net

I am doing a Response.Redirect to below given xml document with a query string parameter.
Response.Redirect(#"../temp/output.xml?location=newlocation");
What I want is that the value of location attribute for all the product nodes should be replaced with the value I pass in query string parameter. The problem is when I do a response.redirect to xml the c# server code which modifies the xml document does not executes for the obvious reason that xml file does not runs any server code.
Can anyone please suggest a solution for this.
Xml File
<?xml version="1.0" encoding="utf-8"?>
<products xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="products:noNamespaceSchemaLocation">
<store id="BND088412">
<display-name>test</display-name>
</store>
<product location="test">
<length units="minutes">100</length>
<title>Microsoft Excel</title>
</product>
<product location="test">
<length units="minutes">300</length>
<title>Microsoft VBA</title>
</product>
</products>
Thanks & Regards

Create XML doc with Linq to XML

I have an ASP .Net site where i am attempting to create a page to allow the user to create an XML document. New with XML so I'm not sure if im missing something here but all i am trying to do is create an XML document using Linq to XML.
I saw this example as part of my research
Dim xmlDoc As XDocument = _
<?xml version="1.0" encoding="utf-16"?>
<!-- This is comment by you -->
<Employees>
<Employee id="EMP001">
<name>Wriju</name>
<![CDATA[ ~~~~~~~...~~~~~~~~]]>
</Employee>
</Employees>
xmlDoc.Save("somepath\somefile.xml")
but i just dont seem to be able to get it working in VS 2010 or VS 2013. As soon as i enter <?xml and enter to the next line i just get errors that the syntax is incorrect. Reading further i have seen some C# examples but they dont seem to be "readable" in VB .Net.
I've tried using online converters but again no luck in that either. Could anyone guide me or point me to the right direction to create an XML document with elements etc using Linq to XML? I think i can use XDocument but i'm a little confused if that would allow me to use Linq to XML or if this is an old concept.
Thanks
Use this
Dim xmlDoc As XDocument = <?xml version="1.0" encoding="utf-16"?>
<!-- This is comment by you -->
<Employees>
<Employee id="EMP001">
<name>Wriju</name>
<![CDATA[ ~~~~~~~...~~~~~~~~]]>
</Employee>
</Employees>
'it assume that /youfolder is in the root and it has read and write permission
xmlDoc.Save(Server.MapPath("/yourfolder/somefile.xml"))

WCF method is returning empty message element

I am calling a typical SOAP WCF method void HelloWorld();
Unfortunately, it is responding as follows:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<HelloWorld xmlns="http://tempuri.org/"/>
</s:Body>
</s:Envelope>
Is there any way I can remove the <HelloWorld xmlns="http://tempuri.org/"/> line from the response (basically having an empty <s:Body>)?
Maybe it will work if you declare this as a "bare" service:
[SoapDocumentService(Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Bare)]
Otherwise implement a custom message inspector (and if it dows not work then a custom message encoder) to change the message.

Web Deploy parameterization of an XML config file where settings are embedded in CDATA elements

During MSDEPLOY.EXE deployment, I am trying to squirt a parameter into an XML configuration file but the configuration values are stored in CDATA elements. Here are the contents of the file, called paths.xml:
<?xml version="1.0" encoding="UTF-8"?>
<course>
<questionnaires><![CDATA[https://www.site.com/somepage.asp]]></questionnaires>
</course>
I need to transform that URL into something different, but I can't figure out the correct XPATH and syntax for my parameters.xml file, here is what I've got now:
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<parameter name="QuestPath" description="Questionnaires path" defaultValue="<questionnaires><![CDATA[https://www.foo.com/somepage.asp]]></questionnaires>" tags="">
<parameterEntry kind="XmlFile" scope="paths.xml$" match="/course/questionnaires" />
</parameter>
</parameters>
I had very little luck referencing the CDATA element to replace it, so you can see I'm now trying to replace the entire questionnaire element including its CDATA contents. I had to do some escaping of the embedded angle-brackets so parameters.xml wasn't rejected due to invalid XML format.
Now, the resultant paths.xml ends up like:
<?xml version="1.0" encoding="UTF-8"?>
<course>
<questionnaires>https://www.foo.com/somepage.asp</questionnaires>
</course>
So, something has resolved the CDATA element down to its contents only, and CDATA no longer appears in paths.xml which I assume will cause the program that reads it to fail. Help!
Okay - I found a much simpler solution. In conjunction with the developer involved in housing this config XML file on our server, we changed it so the elements just contain the raw URLs, completely dispensing with the CDATA structures.
After testing that the consuming application still appeared to work fine, we agreed they were not needed and therefore I was able to do normal XmlFile replacements on nodes referenced like:
...match="/course/questionnaires/text()"

Issue in accessing Sharepoint service from Flex

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/">
<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">
<SOAP-ENV:Body>
<tns:GetListItems xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/"> <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/">
<listName>\{0A3C3DCA-E744-46C7-916D-1D2C539A960F\}</listName>
<viewFields>
<ViewFields>
<FieldRef Name="ID" />
</ViewFields>
</viewFields>
</mx:request>
</mx:operation>
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!

Resources