What is the XML format for an item for the Sitecore Webservice - web-services

I am trying to use the built in web service in Sitecore 6.5 (.../sitecore/shell/webservice/service.asmx)
There is PDF that describes the commands, but it does not specify the format for inserting/updating items. It claims one can simply use the format when doing a GetXml request, but I have found that not to be true from my testing.
I have tried a number of variations, both trying with an or just single fields as suggested by this blog, with no luck and unfortunately the webservice does not complain about the input, it always responds "OK" with no effect.
The full request (as what I am looking at now)
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<Save xmlns="http://sitecore.net/visual/">
<xml>
<sitecore>
<field itemid="{7CCE4419-E8BD-45F4-9B9C-625E220C59A1}"
fieldid="{3F4B20E9-36E6-4D45-A423-C86567373F82}"
language="en"
version="1">
<content>A title from service</content>
</field>
</sitecore>
</xml>
<databaseName>master</databaseName>
<credentials><!-- removed --></credentials>
</Save>
</soapenv:Body>
If anyone knows what the format is that would be great.

If you are using Sitecore 6.5 then you can use the Item Web API, this should give you access to everything you need via JSON REST services.
There was a great response from Kevin Obee with further links, but also have a read of the following:
Sitecore Item Web API and Json.Net Test Drive
New features in Sitecore 6.6 – Webinar

I normally write my own webservice if I want to do some modifications to Sitecore items and found it a much more flexible way because I mostly want at least just a bit more functionality then the standard webservice has to offer. But be aware that you cannot serialize the Sitecore.Data.Items.Item class so sending an Item object through Soap is not going to work.

Related

How to find wsdl version

Can any one please suggest how can I find wsdl version my web service is exposing -
snippet from wsdl -
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://tempuri.org/"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
name="XXXService" targetNamespace="http://tempuri.org/">
I have gone through these web links -
https://coderanch.com/t/502335/certification/determine-wsdl-version
according to above post it's 1.2
whereas looking at this -
https://www.soapui.org/docs/soap-and-wsdl/working-with-wsdls/
SoapUI documentation says "SoapUI supports 1.1 version of the WSDL specification".
Because my wsdl loads successfully in SoapUI - could it be version 1.1?
So, I am not sure which version of wsdl (1.1/1.2/2.0) my web service is exposing.
Any suggestions please.
There are two WSDL versions: 1.1 and 2.0. A history of how these versions got to be can be found on the Wikipedia page for WSDL.
Also on that page it's a useful image of the differences between them and how to recognize the version you are dealing with:
The easiest way is to look at the root element in the XML:
if it's called <definitions> then it's a WSDL 1.1;
if it's called <description> then it's a WSDL 2.0;
Most of the WSDLs you will find out there will be version 1.1, but if the technology is newer, it might also be possible to retrieve a WSDL 2.0. See for example the answer on this post for more details about some conventions of retrieving a SOAP web service's WSDL if it provides one.

Intercept SOAP request

I know this might sound like a duplicate but despite the number of result for this research, I couldn't manage to find a working answer..
I'm using a Java Web service built with Axis (the first one), running on Tomcat v5.5 and a .Net client with some Web reference (not the service reference).
What I want to do is to have a look on the outgoing request from my client, the soap enveloppe.
So far, I tried to use soapUI, great tool, helped me a lot for other thing, but the structure of my web service is quite complexe (array of complexe datatypes) so I have no idea on how I could give him some parameters, here is an exemple of the generated request :
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.main.gimaweb.itrec.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<web:televerserDocument soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<wsi xsi:type="urn:DocumentWSI" xmlns:urn="urn:DocumentWS">
<version xsi:type="xsd:string">?</version>
<documents xsi:type="doc:ArrayOf_tns1_DocumentWVO" soapenc:arrayType="urn:DocumentWVO[]" xmlns:doc="adress"/>
</wsi>
</web:televerserDocument>
</soapenv:Body>
</soapenv:Envelope>
But what i need is an array with data, so there is a lot of xml tag missing for that purpose. Maybe there is a way to generate a more complete sample request? (I don't know if I'm clear enough).
I also tried to use Fiddler, also a great tool but I never managed to get the soap enveloppe, I just got the WSDL from when I update the web reference.
I tried different kind of adresses like :
localhost:port
localhost.:port
ipv4.fiddler:port
hostname:port
But I guess the adress isn't the origin of the problem, I also used ISS Express instead of Visual Studio development server.
Finally, I tried to use some software named Membrane Moniter, but no way to get it, it's becoming quite old, maybe someone knows an alternative
Does someone have a clue on how to do this?
EDIT: And I also tried to use the TCP/IP Monitor on server side, but onece again, I only get the WSDL from the update on VS's side.. I do not really understand why.
EDIT: My Java Webservices are running on Tomcat v5.5, my ASP.Net client is a web application running on IIS Express

Unable to import WSDL in to Visual Studio 2012

Trying to integrate with a PHP SOAP-based web service. The client has given me a URL to a WSDL file which seems to confirm to the W3C Standard for WSDL.
I'm using the Add Web Reference option in the Advanced Dialog to add the reference. When I add the URL, the web browser in the dialog box displays the two methods in the WSDL specification, but there is an error message in the status area on the right, and the Add Reference button is disabled.
Error message:
The document at the url http://www.NAMEHERE.com/NAME/xml/test.php?wsdl was not
recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its nam
If I run the WSDL through an online WSDL validator, it seems right and, like I say, it does appear to conform to standards.
In addition, I've tried using the the WSDL.EXE command-line and tried SOAP, SOAP12, HTTPGET and HTTPPOST protocols, each time getting the same error message.
WSDL Excerpt here:
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.NAMEHERE.com/NAME/xml/namespace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.NAMEHERE.com/NAME/xml/namespace">
<types>
<xsd:schema targetNamespace="http://www.NAMEHERE.com/NAME/xml/namespace">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:complexType name="AddressWO">
....
The cilent says that they haven't experienced this issue with any other partners, who are all able to integrate successfully. Albeit, they are PHP to PHP.
I've searched SO and am unable to find the same issue explicity (or any suitable answer).
Any ideas?
After spending a fair amount of time on this, it turns out that the WSDL wasn't perfect afterall. Our business partner needed to make a couple of minor corrections to the WSDL before Visual Studio could import it.
The issue was that they had a minOccurs attribute on an element, which was invalid in that scenario.
The thing to note here is that several online validators said the WSDL was valid, as do the PHP clients we tried.
Then, we used the WLIMPORT program within JDK 1.6+ and this gave a very detailed list of errors in the WSDL, pointing to the exact cause of the issue.
So, our business partner corrected the specification at their end and now Visual Studio imports the WSDL successfully.
Hope this helps.

Authenticating Office 365 SharePoint Online OOTB services

I want to consume SharePoint data into a non .Net platform. I already use the SharePoint OOTB services like Lists.asmx, Webs.asmx and search.asmx for this purpose.
I have successfully added support for forms based authentication using Authentication.asmx.
Now, I want to provide support for Office 365 SharePoint online. For that purpose I have a demo SharePoint Online site that I am working on.
Problem, I am facing is when I use Mode method of Authentication.asmx I get ‘Forms’ in response:
<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>
<ModeResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<ModeResult>Forms</ModeResult>
</ModeResponse>
</soap:Body>
</soap:Envelope>
However when I use Login.asmx and pass correct username and password, I get ‘PasswordNotMatch’ error, the same credentials are working fine in browser.
<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>
<LoginResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<LoginResult>
<ErrorCode>PasswordNotMatch</ErrorCode>
<TimeoutSeconds>0</TimeoutSeconds>
</LoginResult>
</LoginResponse>
</soap:Body>
</soap:Envelope>
Note:- This works perfect for a FBA non Office 365 SharePoint site.
Could somebody please help me in implementing the support for Office 365 SharePoint Online OOTB services?
I've been looking into a similar idea and this thread has been extremely helpful. They actually have a webservice sample using the PInvoke, it might help you get there.
Edit: my search led me to this other post by Wictor Wilen, but trying to avoid the ClientOM for now.
Edit2: alright, got this working. Using the code from Wictor above, I downloaded his sample solution and moved "MsOnlineClaimsHelper.cs" and "WcfClientContracts.cs" to my project, I will be fiddling with what is really used from these files later. I only changed them to remove the ClientOM references including the clientContext_ExecutingWebRequest method.
In a sample MVC3 app or Console app:
MsOnlineClaimsHelper claimsHelper = new MsOnlineClaimsHelper("https://my365site.sharepoint.com/sites/enterprise/", "admin#my365site.onmicrosoft.com", "secret");
using (var lists = new SharePointLists.Lists())
{
lists.Url = #"https://my365site.sharepoint.com/sites/enterprise/_vti_bin/lists.asmx";
lists.CookieContainer = claimsHelper.CookieContainer;
var listCol = lists.GetListCollection();
ViewBag.Message = listCol.InnerXml;
//Console.Write(listCol.InnerXml);
}

Delphi 2007 generating incorrect SOAP messages

I am writing an application in Delphi 2007 which consumes a web service. I used the WSDL importer to generate the necessary code to communicate with the service, but I'm getting "unexpected subelement (elementname)" errors when trying to use the service.
Using Fiddler 2, I've found that the problem is that an xmlns is being added to an array of values sent in the SOAP message:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="..." xmlns:xsd="..." xmlns:xsi="...">
<SOAP-ENV:Body>
<Request xmlns="http://service.com/theService/">
<UserName xmlns="">user</UserName>
<Password xmlns="">pass</Password>
<List xmlns="">
<Item xmlns="http://service.com/theService/">123456</Item>
<Item xmlns="http://service.com/theService/">84547</Item>
</List>
</Request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
If I resend the message created by Delphi in Fiddler, changing the xmlns for Item elements to an empty string, I no longer get an error, and the service responds properly. ie:
<List xmlns="">
<Item xmlns="">123456</Item>
<Item xmlns="">84547</Item>
</List>
Now, I am able to get rid of the xmlns attribute for list items by changing part of the initialization of my service class from:
InvRegistry.RegisterInvokeOptions(TypeInfo(ServicePort), ioDocument);
InvRegistry.RegisterInvokeOptions(TypeInfo(ServicePort), ioLiteral);
RemClassRegistry.RegisterSerializeOptions(RequestType, [xoLiteralParam]);
to:
InvRegistry.RegisterInvokeOptions(TypeInfo(ServicePort), ioDocument);
RemClassRegistry.RegisterSerializeOptions(RequestType, [xoHolderClass, xoLiteralParam]);
However, this will then cause the Request element name to be changed to the name of the default SOAP action (ex. GetInformation), which will again cause an error. I've been struggling with this for way too long, any ideas would be appreciated.
Also, I've created a test C# app which consumes the service, and it doesn't have any problems communicating with the service.
I've spoken with other people who have had similar problems with serialization in Delphi, and it seems that there is no clear-cut way to fix this issue.
Instead, the solution I've gone with is to attach an event handler to the OnBeforeExecute event of the THTTPRIO object that sends the SOAP message, which gives you access to the serialized soap message as a string. From there I just parsed out the attribute that was causing the problem, and now everything works.
A bit of an ugly solution, but it works.