Skip to content

Commit

Permalink
a couple wsdl fixes, now parses a bit more without warnings and such
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/SOAP/trunk@83110 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Shane Caraveo committed May 21, 2002
1 parent b4dee19 commit 4de3823
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions WSDL.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* TODO:
* add wsdl caching
* refactor namespace handling ($namespace/$ns)
* implement IDL type syntax declaration so we can generate WSDL
*
* @access public
Expand Down Expand Up @@ -89,9 +90,11 @@ function getEndpoint($portName)
// find the name of the first port that contains an operation of name $operation
function getPortName($operation)
{
foreach ($this->services[$this->service]['ports'] as $port => $portAttrs) {
if ($this->bindings[$portAttrs['binding']]['operations'][$operation] != '') {
return $port;
if (isset($this->services[$this->service]['ports'])) {
foreach ($this->services[$this->service]['ports'] as $port => $portAttrs) {
if ($this->bindings[$portAttrs['binding']]['operations'][$operation] != '') {
return $port;
}
}
}
return $this->raiseSoapFault("no operation $operation in wsdl", $this->uri);
Expand Down Expand Up @@ -170,9 +173,9 @@ function addNamespace($namespace) {
if (array_key_exists($namespace, $this->ns)) {
return $this->ns[$namespace];
}
$this->nsc++;
$attr = 'ns'.$this->nsc;
$this->namespaces['ns'.$this->nsc] = $namespace;
$n = count($this->ns);
$attr = 'ns'.$n;
$this->namespaces['ns'.$n] = $namespace;
$this->ns[$namespace] = $attr;
return $attr;
}
Expand Down Expand Up @@ -507,7 +510,11 @@ function startElement($parser, $name, $attrs) {
break;
default:
if ($this->currentOperation) {
$this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name] = array_merge($this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name],$attrs);
if (isset($this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name])) {
$this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name] = array_merge($this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name],$attrs);
} else {
$this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name] = $attrs;
}
if (array_key_exists('message',$attrs)) {
$qn = new QName($attrs['message']);
$this->wsdl->portTypes[$this->currentPortType][$this->currentOperation][$name]['message'] = $qn->name;
Expand Down Expand Up @@ -607,7 +614,9 @@ function startElement($parser, $name, $attrs) {
foreach ($attrs as $key => $value) {
if (strstr($key,'xmlns:') !== FALSE) {
$qn = new QName($key);
// XXX need to refactor ns handling
$this->wsdl->namespaces[$qn->name] = $value;
$this->wsdl->ns[$value] = $qn->name;
if ($key == 'targetNamespace' ||
strcasecmp($value,SOAP_SCHEMA)==0) {
$this->soapns[] = strtolower($qn->name);
Expand Down Expand Up @@ -638,7 +647,8 @@ function endElement($parser, $name)
array_pop($this->schema_stack);
if (count($this->schema_stack) <= 1) {
/* correct the type for sequences with multiple elements */
if ($this->wsdl->complexTypes[$this->schema][$this->currentElement]['type'] == 'Array'
if (isset($this->wsdl->complexTypes[$this->schema][$this->currentElement]['type'])
&& $this->wsdl->complexTypes[$this->schema][$this->currentElement]['type'] == 'Array'
&& array_key_exists('elements',$this->wsdl->complexTypes[$this->schema][$this->currentElement])
&& count($this->wsdl->complexTypes[$this->schema][$this->currentElement]['elements']) > 1) {
$this->wsdl->complexTypes[$this->schema][$this->currentElement]['type'] = 'Struct';
Expand Down

0 comments on commit 4de3823

Please sign in to comment.