📄 class.wsdl.php
字号:
}
$value = $value->value;
$forceType = true;
$this->debug( "in serializeType: soapval overrides type to {$type}, value to {$value}" );
}
else
{
$forceType = false;
}
$xml = "";
if ( strpos( $type, ":" ) )
{
$uqType = substr( $type, strrpos( $type, ":" ) + 1 );
$ns = substr( $type, 0, strrpos( $type, ":" ) );
$this->debug( "got a prefixed type: {$uqType}, {$ns}" );
if ( $this->getnamespacefromprefix( $ns ) )
{
$ns = $this->getnamespacefromprefix( $ns );
$this->debug( "expanded prefixed type: {$uqType}, {$ns}" );
}
if ( $ns == $this->XMLSchemaVersion )
{
if ( is_null( $value ) )
{
if ( $use == "literal" )
{
return "<{$name}/>";
}
else
{
return "<{$name} xsi:nil=\"true\"/>";
}
}
if ( $uqType == "boolean" && !$value )
{
$value = "false";
}
else if ( $uqType == "boolean" )
{
$value = "true";
}
if ( $uqType == "string" && gettype( $value ) == "string" )
{
$value = $this->expandentities( $value );
}
if ( !$this->gettypedef( $uqType, $ns ) )
{
if ( $use == "literal" )
{
if ( $forceType )
{
return "<{$name} xsi:type=\"".$this->getprefixfromnamespace( $this->XMLSchemaVersion ).":{$uqType}\">{$value}</{$name}>";
}
else
{
return "<{$name}>{$value}</{$name}>";
}
}
else
{
return "<{$name} xsi:type=\"".$this->getprefixfromnamespace( $this->XMLSchemaVersion ).":{$uqType}\"{$encodingStyle}>{$value}</{$name}>";
}
}
}
else if ( $ns == "http://xml.apache.org/xml-soap" )
{
if ( $uqType == "Map" )
{
$contents = "";
foreach ( $value as $k => $v )
{
$this->debug( "serializing map element: key {$k}, value {$v}" );
$contents .= "<item>";
$contents .= $this->serialize_val( $k, "key", false, false, false, false, $use );
$contents .= $this->serialize_val( $v, "value", false, false, false, false, $use );
$contents .= "</item>";
}
if ( $use == "literal" )
{
if ( $forceType )
{
return "<{$name} xsi:type=\"".$this->getprefixfromnamespace( "http://xml.apache.org/xml-soap" ).":{$uqType}\">{$contents}</{$name}>";
}
else
{
return "<{$name}>{$contents}</{$name}>";
}
}
else
{
return "<{$name} xsi:type=\"".$this->getprefixfromnamespace( "http://xml.apache.org/xml-soap" ).":{$uqType}\"{$encodingStyle}>{$contents}</{$name}>";
}
}
}
}
else
{
$this->debug( "No namespace for type {$type}" );
$ns = "";
$uqType = $type;
}
if ( !( $typeDef = $this->gettypedef( $uqType, $ns ) ) )
{
$this->seterror( "{$type} ({$uqType}) is not a supported type." );
$this->debug( "{$type} ({$uqType}) is not a supported type." );
return false;
}
else
{
foreach ( $typeDef as $k => $v )
{
$this->debug( "typedef, {$k}: {$v}" );
}
}
$phpType = $typeDef['phpType'];
$this->debug( "serializeType: uqType: {$uqType}, ns: {$ns}, phptype: {$phpType}, arrayType: ".( isset( $typeDef['arrayType'] ) ? $typeDef['arrayType'] : "" ) );
if ( $phpType == "struct" )
{
if ( isset( $typeDef['typeClass'] ) && $typeDef['typeClass'] == "element" )
{
$elementName = $uqType;
if ( isset( $typeDef['form'] ) && $typeDef['form'] == "qualified" )
{
$elementNS = " xmlns=\"{$ns}\"";
}
}
else
{
$elementName = $name;
$elementNS = "";
}
if ( is_null( $value ) )
{
if ( $use == "literal" )
{
return "<{$elementName}{$elementNS}/>";
}
else
{
return "<{$elementName}{$elementNS} xsi:nil=\"true\"/>";
}
}
if ( $use == "literal" )
{
if ( $forceType )
{
$xml = "<{$elementName}{$elementNS} xsi:type=\"".$this->getprefixfromnamespace( $ns ).":{$uqType}\">";
}
else
{
$xml = "<{$elementName}{$elementNS}>";
}
}
else
{
$xml = "<{$elementName}{$elementNS} xsi:type=\"".$this->getprefixfromnamespace( $ns ).":{$uqType}\"{$encodingStyle}>";
}
if ( isset( $typeDef['elements'] ) && is_array( $typeDef['elements'] ) )
{
if ( is_array( $value ) )
{
$xvalue = $value;
}
else if ( is_object( $value ) )
{
$xvalue = get_object_vars( $value );
}
else
{
$this->debug( "value is neither an array nor an object for XML Schema type {$ns}:{$uqType}" );
$xvalue = array( );
}
if ( count( $typeDef['elements'] ) != count( $xvalue ) )
{
$optionals = true;
}
foreach ( $typeDef['elements'] as $eName => $attrs )
{
if ( isset( $optionals ) && !isset( $xvalue[$eName] ) )
{
}
else
{
if ( isset( $xvalue[$eName] ) )
{
$v = $xvalue[$eName];
}
else
{
$v = null;
}
if ( isset( $attrs['maxOccurs'] ) && $attrs['maxOccurs'] == "unbounded" && isset( $v ) && is_array( $v ) && $this->isarraysimpleorstruct( $v ) == "arraySimple" )
{
$vv = $v;
foreach ( $vv as $k => $v )
{
if ( isset( $attrs['type'] ) )
{
$xml .= $this->serializetype( $eName, $attrs['type'], $v, $use, $encodingStyle );
}
else
{
$this->debug( "calling serialize_val() for {$v}, {$eName}, false, false, false, false, {$use}" );
$xml .= $this->serialize_val( $v, $eName, false, false, false, false, $use );
}
}
}
else if ( isset( $attrs['type'] ) )
{
$xml .= $this->serializetype( $eName, $attrs['type'], $v, $use, $encodingStyle );
}
else
{
$this->debug( "calling serialize_val() for {$v}, {$eName}, false, false, false, false, {$use}" );
$xml .= $this->serialize_val( $v, $eName, false, false, false, false, $use );
}
}
}
}
else
{
$this->debug( "Expected elements for XML Schema type {$ns}:{$uqType}" );
}
$xml .= "</{$elementName}>";
}
else if ( $phpType == "array" )
{
if ( isset( $typeDef['form'] ) && $typeDef['form'] == "qualified" )
{
$elementNS = " xmlns=\"{$ns}\"";
}
else
{
$elementNS = "";
}
if ( is_null( $value ) )
{
if ( $use == "literal" )
{
return "<{$name}{$elementNS}/>";
}
else
{
return "<{$name}{$elementNS} xsi:nil=\"true\"/>";
}
}
if ( isset( $typeDef['multidimensional'] ) )
{
$nv = array( );
foreach ( $value as $v )
{
$cols = ",".sizeof( $v );
$nv = array_merge( $nv, $v );
}
$value = $nv;
}
else
{
$cols = "";
}
if ( is_array( $value ) && 1 <= sizeof( $value ) )
{
$rows = sizeof( $value );
$contents = "";
foreach ( $value as $k => $v )
{
$this->debug( "serializing array element: {$k}, {$v} of type: {$typeDef['arrayType']}" );
if ( !in_array( $typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'] ) )
{
$contents .= $this->serializetype( "item", $typeDef['arrayType'], $v, $use );
}
else
{
$contents .= $this->serialize_val( $v, "item", $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use );
}
}
$this->debug( "contents: ".$this->vardump( $contents ) );
}
else
{
$rows = 0;
$contents = null;
}
if ( $use == "literal" )
{
$xml = "<{$name}{$elementNS}>".$contents."</{$name}>";
}
else
{
$xml = "<{$name}{$elementNS} xsi:type=\"".$this->getprefixfromnamespace( "http://schemas.xmlsoap.org/soap/encoding/" ).":Array\" ".$this->getprefixfromnamespace( "http://schemas.xmlsoap.org/soap/encoding/" ).":arrayType=\"".$this->getprefixfromnamespace( $this->getprefix( $typeDef['arrayType'] ) ).":".$this->getlocalpart( $typeDef['arrayType'] )."[{$rows}{$cols}]\">".$contents."</{$name}>";
}
}
else if ( $phpType == "scalar" )
{
if ( isset( $typeDef['form'] ) && $typeDef['form'] == "qualified" )
{
$elementNS = " xmlns=\"{$ns}\"";
}
else
{
$elementNS = "";
}
if ( $use == "literal" )
{
if ( $forceType )
{
return "<{$name}{$elementNS} xsi:type=\"".$this->getprefixfromnamespace( $ns ).":{$uqType}\">{$value}</{$name}>";
}
else
{
return "<{$name}{$elementNS}>{$value}</{$name}>";
}
}
else
{
return "<{$name}{$elementNS} xsi:type=\"".$this->getprefixfromnamespace( $ns ).":{$uqType}\"{$encodingStyle}>{$value}</{$name}>";
}
}
$this->debug( "returning: ".$this->vardump( $xml ) );
return $xml;
}
function addcomplextype( $name, $typeClass = "complexType", $phpType = "array", $compositor = "", $restrictionBase = "", $elements = array( ), $attrs = array( ), $arrayType = "" )
{
if ( 0 < count( $elements ) )
{
foreach ( $elements as $n => $e )
{
foreach ( $e as $k => $v )
{
$k = strpos( $k, ":" ) ? $this->expandqname( $k ) : $k;
$v = strpos( $v, ":" ) ? $this->expandqname( $v ) : $v;
$ee[$k] = $v;
}
$eElements[$n] = $ee;
}
$elements = $eElements;
}
if ( 0 < count( $attrs ) )
{
foreach ( $attrs as $n => $a )
{
foreach ( $a as $k => $v )
{
$k = strpos( $k, ":" ) ? $this->expandqname( $k ) : $k;
$v = strpos( $v, ":" ) ? $this->expandqname( $v ) : $v;
$aa[$k] = $v;
}
$eAttrs[$n] = $aa;
}
$attrs = $eAttrs;
}
$restrictionBase = strpos( $restrictionBase, ":" ) ? $this->expandqname( $restrictionBase ) : $restrictionBase;
$arrayType = strpos( $arrayType, ":" ) ? $this->expandqname( $arrayType ) : $arrayType;
$typens = isset( $this->namespaces['types'] ) ? $this->namespaces['types'] : $this->namespaces['tns'];
$this->schemas[$typens][0]->addcomplextype( $name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType );
}
function addsimpletype( $name, $restrictionBase = "", $typeClass = "simpleType", $phpType = "scalar" )
{
$restrictionBase = strpos( $restrictionBase, ":" ) ? $this->expandqname( $restrictionBase ) : $restrictionBase;
$typens = isset( $this->namespaces['types'] ) ? $this->namespaces['types'] : $this->namespaces['tns'];
$this->schemas[$typens][0]->addsimpletype( $name, $restrictionBase, $typeClass, $phpType );
}
function addoperation( $name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = "rpc", $use = "encoded", $documentation = "" )
{
if ( $style == "rpc" && $use == "encoded" )
{
$encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/";
}
else
{
$encodingStyle = "";
}
$this->bindings[$this->serviceName."Binding"]['operations'][$name] = array(
"name" => $name,
"binding" => $this->serviceName."Binding",
"endpoint" => $this->endpoint,
"soapAction" => $soapaction,
"style" => $style,
"input" => array(
"use" => $use,
"namespace" => $namespace,
"encodingStyle" => $encodingStyle,
"message" => $name."Request",
"parts" => $in
),
"output" => array(
"use" => $use,
"namespace" => $namespace,
"encodingStyle" => $encodingStyle,
"message" => $name."Response",
"parts" => $out
),
"namespace" => $namespace,
"transport" => "http://schemas.xmlsoap.org/soap/http",
"documentation" => $documentation
);
if ( $in )
{
foreach ( $in as $pName => $pType )
{
if ( strpos( $pType, ":" ) )
{
$pType = $this->getnamespacefromprefix( $this->getprefix( $pType ) ).":".$this->getlocalpart( $pType );
}
$this->messages[$name."Request"][$pName] = $pType;
}
}
else
{
$this->messages[$name."Request"] = "0";
}
if ( $out )
{
foreach ( $out as $pName => $pType )
{
if ( strpos( $pType, ":" ) )
{
$pType = $this->getnamespacefromprefix( $this->getprefix( $pType ) ).":".$this->getlocalpart( $pType );
}
$this->messages[$name."Response"][$pName] = $pType;
}
}
else
{
$this->messages[$name."Response"] = "0";
}
return true;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -