• 0

PHP talking to SharePoint


Question

I'm looking at getting PHP talking to SharePoint... Initially just posting an item to a SharePoint list from PHP.

SharePoint exposes a number of web services (http://niklouch.activesharepoint.com/phpint/_vti_bin/Lists.asmx?WSDL).

I am trying to talk to these using SOAP (via the nuSoap PHP library).

I believe I am using it correctly but possibly not. The response I am getting from the server is debugged here (http://www.niklouch.com/sites/work/php_sp/test2.php) - basically:

  Quote
"Server was unable to process request. --> The root element is missing."

Has anyone worked on something like this before?

For reference:

SharePoint SOAP WSDL: http://niklouch.activesharepoint.com/phpin...Lists.asmx?WSDL

SharePoint WebService: http://niklouch.activesharepoint.com/work/...UpdateListItems

My debugged output: http://www.niklouch.com/sites/work/php_sp/test2.php

Code:

<?PHP

/* Requires the NuSOAP library */
require_once('nusoaplib/nusoap.php');

/* Username and password, separated by a colon. Domain may be optional, depending on setup */
$auth = "webtest:webtest";

/* Location of the Lists.asmx file */
$wsdl = "http://niklouch.activesharepoint.com/phpint/_vti_bin/Lists.asmx?WSDL";

/* GUID of the list */
$guid = "{48A2B76C-2E23-4ED0-9C12-DC98897C228A}";

/* Setup NuSOAP. Sharepoint requires NTLM Authorization. Recent version of CURL needed for this */
$client = new nusoap_client($wsdl, true);
$client->setCredentials("","","ntlm");
$client->setCurlOption(CURLOPT_USERPWD, $auth);

$err = $client->getError();
if ($err) {
	echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
	echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
	exit();
}

/* XML for the request */
$xml = '
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">t;listName>'.$guid.'</listName>
	<updates>
		<Batch>
			<Method ID="1" Cmd="New">
				<Field Name="ID" />
				<Field Name="Title">My Title</Field>
			</Method>
		</Batch>
	</updates>
</UpdateListItems>
';

/* Invoke the Web Service */
$result = $client->call('UpdateListItems', $xml);

/* Check for Errors */
if(isset($fault)) {
	echo("<h2>Error</h2>". $fault);
}

/* Debugging Info */
echo("<h2>Request</h2><pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>");
echo("<h2>Response</h2><pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>");
echo("<h2>Debug</h2><pre>" . htmlspecialchars($client->debug_str, ENT_QUOTES) . "</pre>");

unset($client);
?>

Link to comment
https://www.neowin.net/forum/topic/773860-php-talking-to-sharepoint/
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Oh I'm posting 1 item with just a title, nothing more. Never really got into the whole web services over PHP thing. May need to try another webservice (simpler) first and then move on to this...

But it's been set as my "Get this working for your 1st day of work" task for my new job! :s

  • 0

Yeah, I'm not the best person to ask either, however the above worked once for me doing something similar.

Maybe the problem is that you are only posting a title? I'm assuming theres a content section this title is applied to (unless its a name of a directory or something?) That could possibly be what its relating to when returning 'The root element is missing'.

EDIT: Btw, what the new job? Your confused smiley makes it seem your not sure why they asked you do this.. are you being asked to do this by those who think that because your in the I.T department somewhere you should know all everything computer related ever?

  • 0

LOL - no I made a sharepoint list that just contains a title, nothing more. And the confused smiley is sorta because this was not advertised as part of the role, but I mentioned I was also a SharePoint developer, and so they sprung into "Wow - we want a SharePoint connector for our product"... Makes sense totally, but PHP and SharePoint are two languages never destined to play well together, and "SharePoint development" to me has always been within either the SharePoint environment or at least with .net based languages - so I can use the .net libraries...

It would be a VERY cool piece of engineering, and I know how I wanna make it - but it just isn't seeming to work.

  • 0

I'm really not sure.. Never tried using PHP with any other language yet, just starting to really get to grips with PHP itself only recently.

This is probably wrong, but when I go to activesharepoint.com it asks me to login to web2003.activeisp.com, is it possible your wsdl variable is set to the wrong target?

  • 0

Is it necessary for NuSoap library that the sharepoint site must allow anonymous access? Well, I want to do the same but I am not able to do. I searched alot and alot but didn't find any solution which worked for me :(

Can you please help.

Thanks

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I mean they have been proven to be safer than human drivers in many cases so at the end of the day they will be allowed on the road, the fact that you don't trust them doesn't mean that policy has to be changed to make you more comfortable I am afraid.
    • This 4TB Gen4 2280 NVMe SSD is selling for just $200 with promo coupon by Sayan Sen We reported yesterday about the WD_BLACK SN8100 (PCIe Gen5) and SN7100 (PCIe Gen4) deals as they are both priced the lowest. There is also a free VPN on offer. You can check those deals out here. If you do not quite have the budget for those drives but still want a relatively fast drive in 4TB, then Team Group is offering its T-FORCE G50 model at a great price of just $200 with a coupon code (purchase link down below). Like the SN8100 and SN7100 WD SKUs, the Team Group G50 is also a TLC (triple level cell) NAND flash SSD, and thus the endurance on the T-FORCE SSD is quite good, as it is rated for 2600 TBW (terabytes written). Its MTBF, or Mean Time Between Failure, is claimed at 3,000,000 hours. However, unlike the WD_BLACK models, the G50 does not have a dedicated DRAM cache (only the G50 Pro SKUs have it) but it is based on NVMe version 1.4 which supports HMB (host memory buffer) technology; thus, the drive can use system memory for caching. In terms of performance, Team Group promises sequential read and write speeds of up to 5000 MB/s and 4500 MB/s, respectively. However, the firm does not disclose random throughput metrics. Essentially, compared to the WD_BLACK SN7100 linked above, you miss out on faster speeds, but you are also paying less with this. Either of these drives can be a great choice depending on your budget. Get the Team Group SSD at the link below: Team Group T-FORCE G50 M.2 2280 4TB PCIe 4.0 x4 - TM8FFE004T0C129: $219.99 + $20 off with promo code SUMET9324, limited offer => $199.99 (Shipped and Sold by Newegg US) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • Two Point Hospital is free to claim on the Epic Games Store by Pulasthi Ariyasinghe With the Mega Sale coming to an end, the Epic Games Store has returned to offering its regular giveaways promotion. This week, replacing the Deathloop, Ogu, and Secret Forest freebies, Two Point Hospital has landed for all PC gamers to claim. Coming in from Two Point Studios, this 2018-released hospital building and management game offers a humorous take on the genre and is poised as a spiritual successor to the classic Theme Hospital from 1997. The title has you constructing various rooms that diagnose and treat patients with unique and bizarre illnesses that range from Jazz Hands and Bed Face to Lycanthropy. The hospital staff must also be hired and taken care of with exclusive amenities and pay raises to keep morale high. At the same time, players also must make sure to keep the hospital's reputation and profits in good standing. There are multiple regions to play through, with each hospital in a region giving players different goals and obstacles to tackle. This is the base game that's being given away, but there's plenty of DLC available for those who want even more hospital regions and wacky diseases in their game. Here's how the studio describes the curing illnesses process: Two Point Hospital is now free to claim on the Epic Games Store. The Sega-published title usually costs $29.99 to purchase when not on sale, but here it's yours to keep without paying a dime. The next giveaway in the store, which will arrive as a replacement for this offer, is slated to kick off on June 19.
    • Claim your VideoProc Converter AI v7.5 ($78.90 Value) free license by Steven Parker Claim your free license (worth $78.90) today, before the offer expires on June 18. Download a licensed copy of VideoProc Converter AI V6.4 (for Windows) for free. Equipped with AI tools for video and image enhancement, smoothness, and stabilization. Remaster low-quality videos and photos, convert, edit, compress, download, and record with GPU acceleration! Key Features of VideoProc Converter AI V7.5: AI Video Upscaling: Upscale low-res, old, grainy videos/DVDs/recordings by 400% to HD/4K for stunning visuals on larger screens. AI Image Enhancement: Upscale images and AI art to 8K/10K for better cropping, editing, printing, and sharing. AI Stabilization: Intelligently stabilize shaky GoPro/drone/camera footage with controllable cropping ratios. AI Frame Interpolation: Boost FPS from 30/60 to silky-smooth 120/240/480, or create epic slow-motion effects. 5-in-1 Video Toolkit: Convert, edit, compress, download, and record with the highest possible quality. GPU Acceleration: Expedite video processing, even on older computers. How to get it Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last! Download VideoProc Converter AI V7.5 ($78.90 Value, now FREE) Offered by Digiarty, view other free resources The below offers are also available for free in exchange for your (work) email: Unruly: Fighting Back when Politics, AI, and Law Upend [...] ($18 Value) FREE - Expires 6/17 SQL Essentials For Dummies ($10 Value) FREE – Expires 6/17 Continuous Testing, Quality, Security, and Feedback ($27.99 Value) FREE – Expires 6/18 VideoProc Converter AI v7.5 for FREE (worth $78.90) – Expires 6/18 Macxvideo AI ($39.95 Value) Free for a Limited Time – Expires 6/22 The Ultimate Linux Newbie Guide – Featured Free content Python Notes for Professionals – Featured Free content Learn Linux in 5 Days – Featured Free content Quick Reference Guide for Cybersecurity – Featured Free content We post these because we earn commission on each lead so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin The above deal not doing it for you, but still want to help? Check out the links below. Check out our partner software in the Neowin Store Buy a T-shirt at Neowin's Threadsquad Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: An account at Neowin Deals is required to participate in any deals powered by our affiliate, StackCommerce. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through the branded deals site.
  • Recent Achievements

    • Week One Done
      fashionuae earned a badge
      Week One Done
    • One Month Later
      fashionuae earned a badge
      One Month Later
    • Week One Done
      elsafaacompany earned a badge
      Week One Done
    • Week One Done
      Yianis earned a badge
      Week One Done
    • Veteran
      Travesty went up a rank
      Veteran
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      ATLien_0
      262
    3. 3
      +FloatingFatMan
      191
    4. 4
      +Edouard
      175
    5. 5
      snowy owl
      126
  • Tell a friend

    Love Neowin? Tell a friend!