📄 nusoap.php
字号:
}
if ( strpos( $v, "[,]" ) )
{
$this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
}
$v = substr( $v, 0, strpos( $v, "[" ) );
if ( !strpos( $v, ":" ) && isset( $this->typemap[$this->XMLSchemaVersion][$v] ) )
{
$v = $this->XMLSchemaVersion.":".$v;
}
$this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
break;
case "complexType" :
if ( isset( $attrs['name'] ) )
{
$this->xdebug( "processing named complexType ".$attrs['name'] );
$this->currentElement = false;
$this->currentComplexType = $attrs['name'];
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = "complexType";
if ( isset( $attrs['base'] ) && ereg( ":Array\$", $attrs['base'] ) )
{
$this->complexTypes[$this->currentComplexType]['phpType'] = "array";
}
else
{
$this->complexTypes[$this->currentComplexType]['phpType'] = "struct";
}
}
else
{
$this->xdebug( "processing unnamed complexType for element ".$this->currentElement );
$this->currentComplexType = $this->currentElement."_ContainedType";
$this->currentElement = false;
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = "complexType";
if ( isset( $attrs['base'] ) && ereg( ":Array\$", $attrs['base'] ) )
{
$this->complexTypes[$this->currentComplexType]['phpType'] = "array";
}
else
{
$this->complexTypes[$this->currentComplexType]['phpType'] = "struct";
}
}
break;
case "element" :
if ( isset( $attrs['type'] ) )
{
$this->xdebug( "processing typed element ".$attrs['name']." of type ".$attrs['type'] );
$this->currentElement = $attrs['name'];
$this->elements[$attrs['name']] = $attrs;
$this->elements[$attrs['name']]['typeClass'] = "element";
if ( !isset( $this->elements[$attrs['name']]['form'] ) )
{
$this->elements[$attrs['name']]['form'] = $this->schemaInfo['elementFormDefault'];
}
$ename = $attrs['name'];
}
else if ( isset( $attrs['ref'] ) )
{
$ename = $attrs['ref'];
}
else
{
$this->xdebug( "processing untyped element ".$attrs['name'] );
$this->currentElement = $attrs['name'];
$this->elements[$attrs['name']] = $attrs;
$this->elements[$attrs['name']]['typeClass'] = "element";
$this->elements[$attrs['name']]['type'] = $this->schemaTargetNamespace.":".$attrs['name']."_ContainedType";
if ( !isset( $this->elements[$attrs['name']]['form'] ) )
{
$this->elements[$attrs['name']]['form'] = $this->schemaInfo['elementFormDefault'];
}
}
if ( !( isset( $ename ) && $this->currentComplexType ) )
{
break;
}
$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
break;
case "import" :
if ( isset( $attrs['schemaLocation'] ) )
{
$this->imports[$attrs['namespace']][] = array(
"location" => $attrs['schemaLocation'],
"loaded" => false
);
}
else
{
$this->imports[$attrs['namespace']][] = array(
"location" => "",
"loaded" => true
);
if ( $this->getprefixfromnamespace( $attrs['namespace'] ) )
{
break;
}
$this->namespaces["ns".( count( $this->namespaces ) + 1 )] = $attrs['namespace'];
}
break;
case "restriction" :
if ( $this->currentElement )
{
$this->elements[$this->currentElement]['type'] = $attrs['base'];
}
else
{
if ( $this->currentSimpleType )
{
$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
}
else
{
if ( !$this->currentComplexType )
{
break;
}
$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
if ( !( strstr( $attrs['base'], ":" ) == ":Array" ) )
{
break;
}
$this->complexTypes[$this->currentComplexType]['phpType'] = "array";
}
}
break;
case "schema" :
$this->schemaInfo = $attrs;
$this->schemaInfo['schemaVersion'] = $this->getnamespacefromprefix( $prefix );
if ( isset( $attrs['targetNamespace'] ) )
{
$this->schemaTargetNamespace = $attrs['targetNamespace'];
}
if ( isset( $attrs['elementFormDefault'] ) )
{
break;
}
$this->schemaInfo['elementFormDefault'] = "unqualified";
break;
case "simpleType" :
if ( !isset( $attrs['name'] ) )
{
break;
}
$this->xdebug( "processing simpleType for name ".$attrs['name'] );
$this->currentSimpleType = $attrs['name'];
$this->simpleTypes[$attrs['name']] = $attrs;
$this->simpleTypes[$attrs['name']]['typeClass'] = "simpleType";
$this->simpleTypes[$attrs['name']]['phpType'] = "scalar";
break;
default :
}
}
function schemaendelement( $parser, $name )
{
--$this->depth;
if ( isset( $this->depth_array[$this->depth] ) )
{
$pos = $this->depth_array[$this->depth];
}
if ( $name == "complexType" )
{
$this->currentComplexType = false;
$this->currentElement = false;
}
if ( $name == "element" )
{
$this->currentElement = false;
}
if ( $name == "simpleType" )
{
$this->currentSimpleType = false;
}
}
function schemacharacterdata( $parser, $data )
{
$pos = $this->depth_array[$this->depth - 1];
$this->message[$pos]['cdata'] .= $data;
}
function serializeschema( )
{
$schemaPrefix = $this->getprefixfromnamespace( $this->XMLSchemaVersion );
$xml = "";
if ( 0 < sizeof( $this->imports ) )
{
foreach ( $this->imports as $ns => $list )
{
foreach ( $list as $ii )
{
if ( $ii['location'] != "" )
{
$xml .= " <{$schemaPrefix}:import location=\"".$ii['location']."\" namespace=\"".$ns."\" />\n";
}
else
{
$xml .= " <{$schemaPrefix}:import namespace=\"".$ns."\" />\n";
}
}
}
}
foreach ( $this->complexTypes as $typeName => $attrs )
{
$contentStr = "";
if ( isset( $attrs['elements'] ) && 0 < count( $attrs['elements'] ) )
{
foreach ( $attrs['elements'] as $element => $eParts )
{
if ( isset( $eParts['ref'] ) )
{
$contentStr .= " <{$schemaPrefix}:element ref=\"{$element}\"/>\n";
}
else
{
$contentStr .= " <{$schemaPrefix}:element name=\"{$element}\" type=\"".$this->contractqname( $eParts['type'] )."\"/>\n";
}
}
}
if ( isset( $attrs['attrs'] ) && 1 <= count( $attrs['attrs'] ) )
{
foreach ( $attrs['attrs'] as $attr => $aParts )
{
$contentStr .= " <{$schemaPrefix}:attribute ref=\"".$this->contractqname( $aParts['ref'] )."\"";
if ( isset( $aParts['http://schemas.xmlsoap.org/wsdl/:arrayType'] ) )
{
$this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
$contentStr .= " wsdl:arrayType=\"".$this->contractqname( $aParts['http://schemas.xmlsoap.org/wsdl/:arrayType'] )."\"";
}
$contentStr .= "/>\n";
}
}
if ( isset( $attrs['restrictionBase'] ) && $attrs['restrictionBase'] != "" )
{
$contentStr = " <{$schemaPrefix}:restriction base=\"".$this->contractqname( $attrs['restrictionBase'] )."\">\n".$contentStr." </{$schemaPrefix}:restriction>\n";
}
if ( isset( $attrs['compositor'] ) && $attrs['compositor'] != "" )
{
$contentStr = " <{$schemaPrefix}:{$attrs['compositor']}>\n".$contentStr." </{$schemaPrefix}:{$attrs['compositor']}>\n";
}
else if ( isset( $attrs['elements'] ) && 0 < count( $attrs['elements'] ) || isset( $attrs['attrs'] ) && 0 < count( $attrs['attrs'] ) )
{
$contentStr = " <{$schemaPrefix}:complexContent>\n".$contentStr." </{$schemaPrefix}:complexContent>\n";
}
if ( $contentStr != "" )
{
$contentStr = " <{$schemaPrefix}:complexType name=\"{$typeName}\">\n".$contentStr." </{$schemaPrefix}:complexType>\n";
}
else
{
$contentStr = " <{$schemaPrefix}:complexType name=\"{$typeName}\"/>\n";
}
$xml .= $contentStr;
}
if ( isset( $this->simpleTypes ) && 0 < count( $this->simpleTypes ) )
{
foreach ( $this->simpleTypes as $typeName => $attr )
{
$xml .= " <{$schemaPrefix}:simpleType name=\"{$typeName}\">\n <restriction base=\"".$this->contractqname( $eParts['type'] )."\"/>\n </{$schemaPrefix}:simpleType>";
}
}
if ( isset( $this->elements ) && 0 < count( $this->elements ) )
{
foreach ( $this->elements as $element => $eParts )
{
$xml .= " <{$schemaPrefix}:element name=\"{$element}\" type=\"".$this->contractqname( $eParts['type'] )."\"/>\n";
}
}
if ( isset( $this->attributes ) && 0 < count( $this->attributes ) )
{
foreach ( $this->attributes as $attr => $aParts )
{
$xml .= " <{$schemaPrefix}:attribute name=\"{$attr}\" type=\"".$this->contractqname( $aParts['type'] )."\"\n/>";
}
}
$el = "<{$schemaPrefix}:schema targetNamespace=\"{$this->schemaTargetNamespace}\"\n";
foreach ( array_diff( $this->usedNamespaces, $this->enclosingNamespaces ) as $nsp => $ns )
{
$el .= " xmlns:{$nsp}=\"{$ns}\"\n";
}
$xml = $el.">\n".$xml."</{$schemaPrefix}:schema>\n";
return $xml;
}
function xdebug( $string )
{
$this->debug( "<".$this->schemaTargetNamespace."> ".$string );
}
function getphptype( $type, $ns )
{
if ( isset( $this->typemap[$ns][$type] ) )
{
return $this->typemap[$ns][$type];
}
else
{
if ( isset( $this->complexTypes[$type] ) )
{
return $this->complexTypes[$type]['phpType'];
}
}
return false;
}
function gettypedef( $type )
{
if ( isset( $this->complexTypes[$type] ) )
{
$this->xdebug( "in getTypeDef, found complexType {$type}" );
return $this->complexTypes[$type];
}
else if ( isset( $this->simpleTypes[$type] ) )
{
$this->xdebug( "in getTypeDef, found simpleType {$type}" );
if ( !isset( $this->simpleTypes[$type]['phpType'] ) )
{
$uqType = substr( $this->simpleTypes[$type]['type'], strrpos( $this->simpleTypes[$type]['type'], ":" ) + 1 );
$ns = substr( $this->simpleTypes[$type]['type'], 0, strrpos( $this->simpleTypes[$type]['type'], ":" ) );
$etype = $this->gettypedef( $uqType );
if ( $etype )
{
if ( isset( $etype['phpType'] ) )
{
$this->simpleTypes[$type]['phpType'] = $etype['phpType'];
}
if ( isset( $etype['elements'] ) )
{
$this->simpleTypes[$type]['elements'] = $etype['elements'];
}
}
}
return $this->simpleTypes[$type];
}
else
{
if ( isset( $this->elements[$type] ) )
{
$this->xdebug( "in getTypeDef, found element {$type}" );
if ( !isset( $this->elements[$type]['phpType'] ) )
{
$uqType = substr( $this->elements[$type]['type'], strrpos( $this->elements[$type]['type'], ":" ) + 1 );
$ns = substr( $this->elements[$type]['type'], 0, strrpos( $this->elements[$type]['type'], ":" ) );
$etype = $this->gettypedef( $uqType );
if ( $etype )
{
if ( isset( $etype['phpType'] ) )
{
$this->elements[$type]['phpType'] = $etype['phpType'];
}
if ( isset( $etype['elements'] ) )
{
$this->elements[$type]['elements'] = $etype['elements'];
}
}
else if ( $ns == "http://www.w3.org/2001/XMLSchema" )
{
$this->elements[$type]['phpType'] = "scalar";
}
}
return $this->elements[$type];
}
else if ( isset( $this->attributes[$type] ) )
{
$this->xdebug( "in getTypeDef, found attribute {$type}" );
return $this->attributes[$type];
}
}
$this->xdebug( "in getTypeDef, did not find {$type}" );
return false;
}
function serializetypedef( $type )
{
if ( $typeDef = $this->gettypedef( $type ) )
{
$str .= "<".$type;
if ( is_array( $typeDef['attrs'] ) )
{
foreach ( $attrs as $attName => $data )
{
$str .= " {$attName}=\"{type = ".$data['type']."}\"";
}
}
$str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
if ( 0 < count( $typeDef['elements'] ) )
{
$str .= ">";
foreach ( $typeDef['elements'] as $element => $eData )
{
$str .= $this->serializetypedef( $element );
}
$str .= "</{$type}>";
}
else if ( $typeDef['typeClass'] == "element" )
{
$str .= "></{$type}>";
}
else
{
$str .= "/>";
}
return $str;
}
return false;
}
function typetoform( $name, $type )
{
if ( $typeDef = $this->gettypedef( $type ) )
{
if ( $typeDef['phpType'] == "struct" )
{
$buffer .= "<table>";
foreach ( $typeDef['elements'] as $child => $childDef )
{
$buffer .= "\r\n\t\t\t\t\t<tr><td align='right'>{$childDef['name']} (type: ".$this->getlocalpart( $childDef['type'] )."):</td>\r\n\t\t\t\t\t<td><input type='text' name='parameters[".$name."][{$childDef['name']}]'></td></tr>";
}
$buffer .= "</table>";
}
else if ( $typeDef['phpType'] == "array" )
{
$buffer .= "<table>";
$i = 0;
for ( ; $i < 3; ++$i )
{
$buffer .= "\r\n\t\t\t\t\t<tr><td align='right'>array item (type: {$typeDef['arrayType']}):</td>\r\n\t\t\t\t\t<td><input type='text' name='parameters[".$name."][]'></td></tr>";
}
$buffer .= "</table>";
}
else
{
$buffer .= "<input type='text' name='parameters[{$name}]'>";
}
}
else
{
$buffer .= "<input type='text' name='parameters[{$name}]'>";
}
return $buffer;
}
function addcomplextype( $name, $typeClass = "complexType", $phpType = "array", $compositor = "", $restrictionBase = "", $elements = array( ), $attrs = array( ), $arrayType = "" )
{
$this->complexTypes[$name] = array(
"name" => $name,
"typeClass" => $typeClass,
"phpType" => $phpType,
"compositor" => $compositor,
"restrictionBase" => $restrictionBase,
"elements" => $elements,
"attrs" => $attrs,
"arrayType" => $arrayType
);
$this->xdebug( "addComplexType {$name}: ".$this->vardump( $this->complexTypes[$name] ) );
}
function addsimpletype( $name, $restrictionBase = "", $typeClass = "simpleType", $phpType = "scalar" )
{
$this->simpleTypes[$name] = array(
"name" => $name,
"typeClass" => $typeClass,
"phpType" => $phpType,
"type" => $restrictionBase
);
$this->xdebug( "addSimpleType {$name}: ".$this->vardump( $this->simpleTypes[$name] ) );
}
}
class soapval extends nusoap_base
{
var $title = "NuSOAP";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -