Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * WsdlOperation file.
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the BSD License.
7
 *
8
 * Copyright(c) 2005 by Marcus Nyeholt. All rights reserved.
9
 *
10
 * To contact the author write to {@link mailto:tanus@users.sourceforge.net Marcus Nyeholt}
11
 * This file is part of the PRADO framework from {@link http://www.xisc.com}
12
 *
13
 * @author Marcus Nyeholt		<tanus@users.sourceforge.net>
14
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
 * @version $Id: WsdlOperation.php 1689 2007-02-12 12:46:11Z wei $
16
 * @package System.Web.Services.SOAP
17
 */
18
 
19
/**
20
 * Represents a WSDL Operation. This is exported for the portTypes and bindings
21
 * section of the soap service
22
 * @author 		Marcus Nyeholt		<tanus@users.sourceforge.net>
23
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
24
 * @version 	$Revision$
25
 */
26
class WsdlOperation
27
{
28
	/**
29
	 * The name of the operation
30
	 */
31
	private $operationName;
32
 
33
	/**
34
	 * Documentation for the operation
35
	 */
36
	private $documentation;
37
 
38
	/**
39
	 * The input wsdl message
40
	 */
41
	private $inputMessage;
42
 
43
	/**
44
	 * The output wsdl message
45
	 */
46
	private $outputMessage;
47
 
48
	public function __construct($name, $doc='')
49
	{
50
		$this->operationName = $name;
51
		$this->documentation = $doc;
52
	}
53
 
54
	public function setInputMessage(WsdlMessage $msg)
55
	{
56
		$this->inputMessage = $msg;
57
	}
58
 
59
	public function setOutputMessage(WsdlMessage $msg)
60
	{
61
		$this->outputMessage = $msg;
62
	}
63
 
64
	/**
65
	 * Sets the message elements for this operation into the wsdl document
66
	 * @param 	DOMElement 		$wsdl		The parent domelement for the messages
67
	 * @param 	DomDocument		$dom		The dom document to create the messages as children of
68
	 */
69
	public function setMessageElements(DOMElement $wsdl, DOMDocument $dom)
70
	{
71
 
72
		$input = $this->inputMessage->getMessageElement($dom);
73
		$output = $this->outputMessage->getMessageElement($dom);
74
 
75
		$wsdl->appendChild($input);
76
		$wsdl->appendChild($output);
77
	}
78
 
79
	/**
80
	 * Get the port operations for this operation
81
	 * @param 	DomDocument		$dom		The dom document to create the messages as children of
82
	 * @return 	DomElement					The dom element representing this port.
83
	 */
84
	public function getPortOperation(DomDocument $dom)
85
	{
86
		$operation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:operation');
87
		$operation->setAttribute('name', $this->operationName);
88
 
89
		$documentation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:documentation', htmlentities($this->documentation));
90
		$input = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:input');
91
		$input->setAttribute('message', 'tns:'.$this->inputMessage->getName());
92
		$output = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:output');
93
		$output->setAttribute('message', 'tns:'.$this->outputMessage->getName());
94
 
95
		$operation->appendChild($documentation);
96
		$operation->appendChild($input);
97
		$operation->appendChild($output);
98
 
99
		return $operation;
100
	}
101
 
102
	/**
103
	 * Build the binding operations.
104
	 * TODO: Still quite incomplete with all the things being stuck in, I don't understand
105
	 * a lot of it, and it's mostly copied from the output of nusoap's wsdl output.
106
	 * @param 	DomDocument		$dom		The dom document to create the binding as children of
107
	 * @param 	string			$namespace	The namespace this binding is in.
108
	 * @return 	DomElement					The dom element representing this binding.
109
	 */
110
	public function getBindingOperation(DomDocument $dom, $namespace, $style='rpc')
111
	{
112
		$operation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:operation');
113
		$operation->setAttribute('name', $this->operationName);
114
 
115
		$soapOperation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:operation');
116
		$method = $this->operationName;
117
		$soapOperation->setAttribute('soapAction', $namespace.'#'.$method);
118
		$soapOperation->setAttribute('style', $style);
119
 
120
		$input = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:input');
121
		$output = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:output');
122
 
123
		$soapBody = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:body');
124
		$soapBody->setAttribute('use', 'encoded');
125
		$soapBody->setAttribute('namespace', $namespace);
126
		$soapBody->setAttribute('encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/');
127
		$input->appendChild($soapBody);
128
		$output->appendChild(clone $soapBody);
129
 
130
		$operation->appendChild($soapOperation);
131
		$operation->appendChild($input);
132
		$operation->appendChild($output);
133
 
134
		return $operation;
135
	}
136
}
137
?>