Issue in accessing Sharepoint service from Flex - apache-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!

Related

Mule ESB: How to use MEL expression in Message Properties Key?

I'm using the message-properties component in mule. I need to set a dynamic key name as this is used to add custom headers to a http-request.
<message-properties-transformer doc:name="Message Properties" scope="session">
<add-message-property key="#[flowVars.name]" value="#[payload.split(":")[1]]"/>
</message-properties-transformer>
When logging the output, it shows that the key has not evaluated the MEL expression contained inside:
SESSION scoped properties: #[flowVars.name]=Basic pokpogytg788t878
Is there any way of setting a dynamic key name for a property in this component?
I have faced similar situation,where I had to set dynamic message properties.
I tried several things to set it with message-properties-transformer , but to no luck.
There is some bug filed for similar issue,below is the link
Cannot use MEL expression as key in Message Properties transformer
After trying for sometime I got that working with some workaround.
You can try working it around with Expression component.
<expression-component doc:name="Expression">
<![CDATA[message.outboundProperties[flowVars.name]=payload.split(':')1];]]>
</expression-component>
Not only you can read dynamic values from payload/variables.But you can also call your custom java/groovy methods in it.
Try below code snippet,and let us know if that works for you.
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/test" doc:name="HTTP" allowedMethods="POST" />
<set-variable variableName="name" value="#["test"]"
doc:name="name" />
<expression-component doc:name="Expression">
<![CDATA[message.outboundProperties[flowVars.name]=payload.split(':')1];]]>
</expression-component>
</flow>

Jaxb outputting invalid Xml when data contains xmlns=""

I have jax-ws service implemented using cxf with jaxb binding. It receives xml from another downstream service, Unmarshals this xml in to a POJO and saves it to persistent caching store. Future requests are served from this persistent store. Some times the xml received from downstream service contains xmlns="". The service is able to unmarshal the xml from the persistent caching store but when it marshals back the response to the client, the xml is not well formed.
Here is the xml i.e. received from downstream service. Notice the PolicyID element with xmlns="".
<message:RetrieveOrderResponse
xmlns:common="urn:xyz:om:common:defn:v1" xmlns:message="urn:xyz:om:order:messages:v1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<common:MessageInfo CreateDateTime="2015-04-17T13:13:36.819-07:00"
MessageGUID="d8ad2956-ff69-45ff-9d57-c30dc50569a1" TransactionGUID="a772169a-b138-40e7-8d16-ca86b68d38b8">
<common:DebugTraceBoolean>true</common:DebugTraceBoolean>
</common:MessageInfo>
<common:MessageStatus>
<common:Status>Success</common:Status>
</common:MessageStatus>
<common:OrderList>
<common:Order>
<common:OrderLineList>
<common:OrderLine>
<common:OrderLineData namespace="urn:xyz:e3:data:abc:types:v1"
type="xyzProduct">
<ns2:xyzProduct xmlns:datatype="urn:xyz:om:supply:datatype:defn:v1"
xmlns:finance="urn:xyz:e3:data:financetypes:defn:v4"
xmlns:internal="urn:xyz:cc:es:order:internal" xmlns:min="xalan://org.jaxen.function.MinDateTimeFunction"
xmlns:ns2="urn:xyz:e3:data:abc:types:v1" xmlns:ns3="urn:xyz:e3:data:basetypes:defn:v4"
xmlns:ns4="urn:xyz:e3:data:financetypes:defn:v4" xmlns:ns5="urn:xyz:e3:data:timetypes:defn:v4"
xmlns:ns6="urn:xyz:e3:data:messagetypes:defn:v5" xmlns:ns7="urn:xyz:e3:data:placetypes:defn:v4"
xmlns:ns8="urn:xyz:om:supply:messages:defn:v1">
<PolicyID xmlns="" />
<ns2:abcProduct>
<ns2:DiningSeatingInformation>
<BookingStatusCode xsi:nil="true" />
<DinSeatingCode xsi:nil="true" />
</ns2:DiningSeatingInformation>
</ns2:abcProduct>
</ns2:xyzProduct>
</common:OrderLineData>
</common:OrderLine>
</common:OrderLineList>
</common:Order>
</common:OrderList>
This xml is subjected to the following steps.
unmarshal in to a POJO
marshal the POJO back to xml
unmarshal the xml from step 2 back to POJO
marshal the POJO from step 3 to xml
The resulting xml from step 4 is not well formed. In the example below, the start tag for OrderLineData is bound to valid namespace prefix but the end tag is unbound. If I remove the xmlns="" from the xml then step4 outputs well formed xml. Here is the badly-formed xml.
true
Success
Any hints on how to handle such xml?
Are you using classes generated by some XSD ? if yes make sure you have package-info.java class in the generated package. This class is responsible for namespace handling and it is used during marshal/ unmarshal process.

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.

insert new item in sharepoint list from 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.

WebService remove <xml> tag from my XmlDocument

I use a WebService to transform and XmlDocument into a PDF.
The XmlDocument I send to the Web service looks like this.
<?xml version="1.0" encoding="utf-16" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
...
</fo:root>
I had a problem so I went in debug mod to find out that when the XmlDocument object is transferred from my asp website itself to the Web Service which works on .NET 1.1 sees his
xml tag. Is there a reason why this tag is removed? Could it be caused by the SOAP response?
Is there a way around other than manually add the tag back in the document?
Edit
To answer John's question, yes I mean the processing instruction. It just goes off and I was wondering why because the library I use to convert doesn't work without it. If I manually add it, it works fine but I just wanted to know why it disappear.
Edit 2
Even if it isn't a tag, the library that requires the XmlDocument just doesn't work without it that's why I need it. Other than that, the rest of the document is processed correctly. The generated Reference.cs from the Web Reference looked like this for the called method :
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GeneratePdfFromXml", RequestNamespace="http://tempuri.org", ResponseNamespace="http://tempuri.org", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
public byte[] GeneratePdfFromXml(XmlNode FormattedObjectXml) {
object[] results = this.Invoke("GeneratePdfFromXml", new object[] {
FormattedObjectXml});
return ((byte[])(results[0]));
}
It is the same issue as another problem I had, in which the XmlDocument are referenced as XmlNode since the SOAP response is a XmlDocument itself.
I just changed this to a string ; MyXmlDocument.OuterXml;
That way, everything is kept and no problem.
It is most likely an encoding issue. The XML Declaration is claiming the document is in UTF-16, which is two bytes per character. The other library probably is assuming, in its absence, some other encoding.
You will never get an XML Declaration or processing instruction passed to via an XmlNode, XmlElement or XmlDocument parameter to an ASMX service. The reason is obvious if you think about it. The SOAP Request would be something like:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body>
<parameter>
<?xml version="1.0" encoding="utf-16" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
</fo:root>
</parameter>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But an XML declaration can only appear at the very beginning of the document, so this is invalid.
The solution, as you found, is to send this XML as a string. Make your parameter type string, and either use XmlNode.OuterXml.

Resources