Jump to content

Send dynamically generated XML to webservice?


This topic is 4714 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have an ecommerce site in which the inventory is also listed on another metasite (i.e. amazon, ebay, etc..). The metasite maintains its own separate inventory.

I need to send a xml to the metasite's webservice whenever someone buys an item on my website.

The purpose of this xml is to delete the item off the metasite immediately.

I am using FMStudio for FX.php and Filemaker Pro 11.

The delete xml will be generated upon payment confirmation from the buyer. It is autogenerated as a webpage.

I also have a php page that sends a 'file_get_contents' to the webservice sucessfully - meaning it works just fine when sending an xml file that resides in the same folder.

But I don't know how to integrate the two. The two files do not sit in the same folder so the latter is having a hard time finding the former, and any combination of "../foldername.php" doesn't seem to work.

And i'm not even sure this is the most expedient way to do this so I'm open to any suggestions.

Here is my autogenerated delete xml page in php. Basically it lists the ids of ordered items that reside in a portal on an FM layout called 'orders' -

<?php require_once('Connections/invoices.php'); ?>

<?php $ids_find = clone($invoices);

$ids_find->layout = 'orders';

$ids_findCriterions = array('orderID'=>$_REQUEST['orderid'],);

foreach($ids_findCriterions as $key=>$value) {

$ids_find->AddDBParam($key,$value);

}

fmsSetPage($ids_find,'ids',35);

$ids_result = $ids_find->FMFind();

if(is_a($ids_result,'FX_Error') || $ids_result['errorCode'] != "0") fmsTrapError($ids_result,"error.php");

$ids_row = current($ids_result['data']);

$ids_row_key = key($ids_result['data']);

$ids_orderlineitem_portal_row = 0;

$ids_orderpaypalvars_portal_row = 0;

fmsSetLastPage($ids_result,'ids',35);

fmsRedirect('Books/websitedeleteIndex.php');

//FMStudioFX v1.0 - do not remove comment, needed for DreamWeaver support ?>

<?php

header('content-type: text/xml; charset=utf-8');

echo('<?xml version="1.0" encoding="ISO-8859-1"?>');

echo('<inventoryUpdateRequest version="1.0">');

echo('<action name="bookupdate">');

echo('<username>USERNAME</username>');

echo('<password>ISSECRET</password>');

echo('</action>');

echo('<MetaSiteList>');

$ids_orderlineitem_portal_rownum = 1;

foreach($ids_row['order_line_item::bookID'] as $ids_orderlineitem_portal_row=>$ids_orderlineitem_portal){

echo('<MetaSite>');

echo('<transactionType>delete</transactionType>');

echo('<vendorBookID>'.$ids_row['order_line_item::bookID'][$ids_orderlineitem_portal_row].'</vendorBookID> </MetaSite>');

if($ids_orderlineitem_portal_rownum == 0) break; else $ids_orderlineitem_portal_rownum++;

}//portal_end

echo('</MetaSiteList>');

echo('</inventoryUpdateRequest>');

?>

The xml document appears in a URL formatted correctly. But I don't care for the buyers to see this page, not even a millisecond of it.

Here is the redirected 'Books/websitedeleteIndex.php file -

<?php require_once('post_xml.php');?>

<?php $xml = file_get_contents('updateInventory.php');

$url ='https://inventoryupdate.metasite.com';

$port = 80;

$response = xml_post($xml, $url, $port);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Untitled Document</title>

</head>

<body>

</body>

</html>

I tried <?php $xml = file_get_contents('../updateInventory.php') because it sits one directory level up. Doesn't work.

But there's got to be an easier way to send this info, yes?

Thanks.

Link to comment
Share on other sites

This topic is 4714 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.