XML-Based Services

Web-Based Services (INFOSYS 290-3)

Erik Wilde, UC Berkeley iSchool
Monday, October 2, 2006
Creative Commons License

This work is licensed under a Creative Commons
Attribution-NonCommercial-ShareAlike 2.5 License.

Abstract

Web-based services can be invoked using Web technologies, and provide results in some format. Web-oriented services often provide HTML as the result format, which is not well suited for processing. Application-oriented service often provide XML as the result format, which is easier to process and can be structured specifically for the needs of a service. One of the key questions when designing and using XML-based services is the underlying data model of the XML, and in this lecture we will

Service Interfaces

Outline (Service Interface Design (SID))

  1. Service Interface Design (SID) [6]
  2. XML Interfaces [6]
  3. SimpleXML [9]
    1. XPath Support [2]
    2. PHP-Style Access [2]
    3. Updating XML [2]
  4. Conclusions [1]

What is a Service?

Document Engineering

What is a Service? (2nd Try)

System Models

System and Exchange Models

Model Models

Outline (XML Interfaces)

  1. Service Interface Design (SID) [6]
  2. XML Interfaces [6]
  3. SimpleXML [9]
    1. XPath Support [2]
    2. PHP-Style Access [2]
    3. Updating XML [2]
  4. Conclusions [1]

XML as Data Model

<?xml version="1.0" encoding="UTF-8"?>
<文書 改訂日付="1999年3月1日">
 <題>サンプル</題>
 <段落>これはサンプル文書です。</段落>
 <!-- コメント -->
 <段落>会社名</段落>
 <図面 図面実体名="サンプル" />
</文書>

XML Semantics

Supporting Reuse

Good XML vs. Bad XML

  <topics>
   <topic name="rdf" weight="0.6"/>
   <topic name="shiq" weight="0.6"/>
   <topic name="owl" weight="0.8"/>
  </topics>
  <field type="bibtex:topic">rdf[0.6] shiq[0.6] owl[0.8]</field>

XML Modeling and Design

XML Interfaces

Outline (SimpleXML)

  1. Service Interface Design (SID) [6]
  2. XML Interfaces [6]
  3. SimpleXML [9]
    1. XPath Support [2]
    2. PHP-Style Access [2]
    3. Updating XML [2]
  4. Conclusions [1]

PHP and XML

SimpleXML vs. SDO

SimpleXML Basics

$snoopy->fetch("http://dret.net/lectures/services-fall06/a/4/query.php?format=xml&author=" . urlencode($formval_author));

$xml = new SimpleXMLElement($snoopy->results);

Outline (XPath Support)

  1. Service Interface Design (SID) [6]
  2. XML Interfaces [6]
  3. SimpleXML [9]
    1. XPath Support [2]
    2. PHP-Style Access [2]
    3. Updating XML [2]
  4. Conclusions [1]

XML Path Language (XPath)

SimpleXML XPath Support

<ul>
<?php

include "Snoopy.class.php";
$snoopy = new Snoopy;

import_request_variables("g", "formval_") ;

$snoopy->fetch("http://dret.net/lectures/services-fall06/a/4/query.php?format=xml&author=" . urlencode($formval_author));

$xml = new SimpleXMLElement($snoopy->results);

foreach ($xml->xpath('//title[@type = "sharef:primaryTitle"]') as $title) {
   echo '<li>' , $title , '</li>'; }

?>
</ul>

Outline (PHP-Style Access)

  1. Service Interface Design (SID) [6]
  2. XML Interfaces [6]
  3. SimpleXML [9]
    1. XPath Support [2]
    2. PHP-Style Access [2]
    3. Updating XML [2]
  4. Conclusions [1]

SimpleXML Objects

Potential Problems

Outline (Updating XML)

  1. Service Interface Design (SID) [6]
  2. XML Interfaces [6]
  3. SimpleXML [9]
    1. XPath Support [2]
    2. PHP-Style Access [2]
    3. Updating XML [2]
  4. Conclusions [1]

Adding Nodes

XSLT for Updating XML

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/ | node() | @*">
  <xsl:copy>
   <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
 </xsl:template>
</xsl:stylesheet>

Outline (Conclusions)

  1. Service Interface Design (SID) [6]
  2. XML Interfaces [6]
  3. SimpleXML [9]
    1. XPath Support [2]
    2. PHP-Style Access [2]
    3. Updating XML [2]
  4. Conclusions [1]

PHP and XML