⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.wsdl.php

📁 学校网站源码http://您的网址/admin/admin_login.asp 默认登录用户:admin 默认登录密码:admin
💻 PHP
📖 第 1 页 / 共 3 页
字号:
					if ( strpos( $attrs['name'], ":" ) )
					{
						$this->currentBinding = $this->getlocalpart( $attrs['name'] );
					}
					else
					{
						$this->currentBinding = $attrs['name'];
					}
					$this->status = "binding";
					$this->bindings[$this->currentBinding]['portType'] = $this->getlocalpart( $attrs['type'] );
					$this->debug( "current binding: {$this->currentBinding} of portType: ".$attrs['type'] );
				}
				break;
			case "service" :
				$this->serviceName = $attrs['name'];
				$this->status = "service";
				$this->debug( "current service: ".$this->serviceName );
				break;
			case "definitions" :
				foreach ( $attrs as $name => $value )
				{
					$this->wsdl_info[$name] = $value;
				}
				break;
			}
		}
	}

	function end_element( $parser, $name )
	{
		if ( ereg( "schema\$", $name ) )
		{
			$this->status = "";
			$this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
		}
		if ( $this->status == "schema" )
		{
			$this->currentSchema->schemaendelement( $parser, $name );
		}
		else
		{
			$this->depth--;
		}
		if ( $this->documentation )
		{
			$this->documentation = false;
		}
	}

	function character_data( $parser, $data )
	{
		$pos = isset( $this->depth_array[$this->depth] ) ? $this->depth_array[$this->depth] : 0;
		if ( isset( $this->message[$pos]['cdata'] ) )
		{
			$this->message[$pos]['cdata'] .= $data;
		}
		if ( $this->documentation )
		{
			$this->documentation .= $data;
		}
	}

	function getbindingdata( $binding )
	{
		if ( is_array( $this->bindings[$binding] ) )
		{
			return $this->bindings[$binding];
		}
	}

	function getoperations( $bindingType = "soap" )
	{
		$ops = array( );
		if ( $bindingType == "soap" )
		{
			$bindingType = "http://schemas.xmlsoap.org/wsdl/soap/";
		}
		foreach ( $this->ports as $port => $portData )
		{
			if ( $portData['bindingType'] == $bindingType )
			{
				if ( isset( $this->bindings[$portData['binding']]['operations'] ) )
				{
					$ops = array_merge( $ops, $this->bindings[$portData['binding']]['operations'] );
				}
			}
		}
		return $ops;
	}

	function getoperationdata( $operation, $bindingType = "soap" )
	{
		if ( $bindingType == "soap" )
		{
			$bindingType = "http://schemas.xmlsoap.org/wsdl/soap/";
		}
		foreach ( $this->ports as $port => $portData )
		{
			if ( $portData['bindingType'] == $bindingType )
			{
				foreach ( array_keys( $this->bindings[$portData['binding']]['operations'] ) as $bOperation )
				{
					if ( $operation == $bOperation )
					{
						$opData = $this->bindings[$portData['binding']]['operations'][$operation];
						return $opData;
					}
				}
			}
		}
	}

	function gettypedef( $type, $ns )
	{
		if ( !$ns && isset( $this->namespaces['tns'] ) )
		{
			$ns = $this->namespaces['tns'];
		}
		if ( isset( $this->schemas[$ns] ) )
		{
			foreach ( $this->schemas[$ns] as $xs )
			{
				$t = $xs->gettypedef( $type );
				$this->debug_str .= $xs->debug_str;
				$xs->debug_str = "";
				if ( $t )
				{
					return $t;
				}
			}
		}
		return false;
	}

	function serialize( )
	{
		$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><definitions";
		foreach ( $this->namespaces as $k => $v )
		{
			$xml .= " xmlns:{$k}=\"{$v}\"";
		}
		if ( isset( $this->namespaces['wsdl'] ) )
		{
			$xml .= " xmlns=\"".$this->namespaces['wsdl']."\"";
		}
		if ( isset( $this->namespaces['tns'] ) )
		{
			$xml .= " targetNamespace=\"".$this->namespaces['tns']."\"";
		}
		$xml .= ">";
		if ( 0 < sizeof( $this->import ) )
		{
			foreach ( $this->import as $ns => $list )
			{
				foreach ( $list as $ii )
				{
					if ( $ii['location'] != "" )
					{
						$xml .= "<import location=\"".$ii['location']."\" namespace=\"".$ns."\" />";
					}
					else
					{
						$xml .= "<import namespace=\"".$ns."\" />";
					}
				}
			}
		}
		if ( 1 <= count( $this->schemas ) )
		{
			$xml .= "<types>";
			foreach ( $this->schemas as $ns => $list )
			{
				foreach ( $list as $xs )
				{
					$xml .= $xs->serializeschema( );
				}
			}
			$xml .= "</types>";
		}
		if ( 1 <= count( $this->messages ) )
		{
			foreach ( $this->messages as $msgName => $msgParts )
			{
				$xml .= "<message name=\"".$msgName."\">";
				if ( is_array( $msgParts ) )
				{
					foreach ( $msgParts as $partName => $partType )
					{
						if ( strpos( $partType, ":" ) )
						{
							$typePrefix = $this->getprefixfromnamespace( $this->getprefix( $partType ) );
						}
						else if ( isset( $this->typemap[$this->namespaces['xsd']][$partType] ) )
						{
							$typePrefix = "xsd";
						}
						else
						{
							foreach ( $this->typemap as $ns => $types )
							{
								if ( isset( $types[$partType] ) )
								{
									$typePrefix = $this->getprefixfromnamespace( $ns );
								}
							}
							if ( !isset( $typePrefix ) )
							{
								exit( "{$partType} has no namespace!" );
							}
						}
						$xml .= "<part name=\"".$partName."\" type=\"".$typePrefix.":".$this->getlocalpart( $partType )."\" />";
					}
				}
				$xml .= "</message>";
			}
		}
		if ( 1 <= count( $this->bindings ) )
		{
			$binding_xml = "";
			$portType_xml = "";
			foreach ( $this->bindings as $bindingName => $attrs )
			{
				$binding_xml .= "<binding name=\"".$bindingName."\" type=\"tns:".$attrs['portType']."\">";
				$binding_xml .= "<soap:binding style=\"".$attrs['style']."\" transport=\"".$attrs['transport']."\"/>";
				$portType_xml .= "<portType name=\"".$attrs['portType']."\">";
				foreach ( $attrs['operations'] as $opName => $opParts )
				{
					$binding_xml .= "<operation name=\"".$opName."\">";
					$binding_xml .= "<soap:operation soapAction=\"".$opParts['soapAction']."\" style=\"".$attrs['style']."\"/>";
					if ( isset( $opParts['input']['encodingStyle'] ) && $opParts['input']['encodingStyle'] != "" )
					{
						$enc_style = " encodingStyle=\"".$opParts['input']['encodingStyle']."\"";
					}
					else
					{
						$enc_style = "";
					}
					$binding_xml .= "<input><soap:body use=\"".$opParts['input']['use']."\" namespace=\"".$opParts['input']['namespace']."\"".$enc_style."/></input>";
					if ( isset( $opParts['output']['encodingStyle'] ) && $opParts['output']['encodingStyle'] != "" )
					{
						$enc_style = " encodingStyle=\"".$opParts['output']['encodingStyle']."\"";
					}
					else
					{
						$enc_style = "";
					}
					$binding_xml .= "<output><soap:body use=\"".$opParts['output']['use']."\" namespace=\"".$opParts['output']['namespace']."\"".$enc_style."/></output>";
					$binding_xml .= "</operation>";
					$portType_xml .= "<operation name=\"".$opParts['name']."\"";
					if ( isset( $opParts['parameterOrder'] ) )
					{
						$portType_xml .= " parameterOrder=\"".$opParts['parameterOrder']."\"";
					}
					$portType_xml .= ">";
					if ( isset( $opParts['documentation'] ) && $opParts['documentation'] != "" )
					{
						$portType_xml .= "<documentation>".htmlspecialchars( $opParts['documentation'] )."</documentation>";
					}
					$portType_xml .= "<input message=\"tns:".$opParts['input']['message']."\"/>";
					$portType_xml .= "<output message=\"tns:".$opParts['output']['message']."\"/>";
					$portType_xml .= "</operation>";
				}
				$portType_xml .= "</portType>";
				$binding_xml .= "</binding>";
			}
			$xml .= $portType_xml.$binding_xml;
		}
		$xml .= "<service name=\"".$this->serviceName."\">";
		if ( 1 <= count( $this->ports ) )
		{
			foreach ( $this->ports as $pName => $attrs )
			{
				$xml .= "<port name=\"".$pName."\" binding=\"tns:".$attrs['binding']."\">";
				$xml .= "<soap:address location=\"".$attrs['location']."\"/>";
				$xml .= "</port>";
			}
		}
		$xml .= "</service>";
		return $xml."</definitions>";
	}

	function serializerpcparameters( $operation, $direction, $parameters )
	{
		$this->debug( "in serializeRPCParameters with operation ".$operation.", direction ".$direction." and ".count( $parameters )." param(s), and xml schema version ".$this->XMLSchemaVersion );
		if ( $direction != "input" && $direction != "output" )
		{
			$this->debug( "The value of the \\\$direction argument needs to be either \"input\" or \"output\"" );
			$this->seterror( "The value of the \\\$direction argument needs to be either \"input\" or \"output\"" );
			return false;
		}
		if ( !( $opData = $this->getoperationdata( $operation ) ) )
		{
			$this->debug( "Unable to retrieve WSDL data for operation: ".$operation );
			$this->seterror( "Unable to retrieve WSDL data for operation: ".$operation );
			return false;
		}
		$this->debug( $this->vardump( $opData ) );
		$encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/";
		if ( $direction == "input" && isset( $opData['output']['encodingStyle'] ) && $opData['output']['encodingStyle'] != $encodingStyle )
		{
			$encodingStyle = $opData['output']['encodingStyle'];
			$enc_style = $encodingStyle;
		}
		$xml = "";
		if ( isset( $opData[$direction]['parts'] ) && 0 < sizeof( $opData[$direction]['parts'] ) )
		{
			$use = $opData[$direction]['use'];
			$this->debug( "use={$use}" );
			$this->debug( "got ".count( $opData[$direction]['parts'] )." part(s)" );
			if ( is_array( $parameters ) )
			{
				$parametersArrayType = $this->isarraysimpleorstruct( $parameters );
				$this->debug( "have ".$parametersArrayType." parameters" );
				foreach ( $opData[$direction]['parts'] as $name => $type )
				{
					$this->debug( "serializing part \"".$name."\" of type \"".$type."\"" );
					if ( isset( $opData[$direction]['encodingStyle'] ) && $encodingStyle != $opData[$direction]['encodingStyle'] )
					{
						$encodingStyle = $opData[$direction]['encodingStyle'];
						$enc_style = $encodingStyle;
					}
					else
					{
						$enc_style = false;
					}
					if ( $parametersArrayType == "arraySimple" )
					{
						$p = array_shift( $parameters );
						$this->debug( "calling serializeType w/indexed param" );
						$xml .= $this->serializetype( $name, $type, $p, $use, $enc_style );
					}
					else if ( isset( $parameters[$name] ) )
					{
						$this->debug( "calling serializeType w/named param" );
						$xml .= $this->serializetype( $name, $type, $parameters[$name], $use, $enc_style );
					}
					else
					{
						$this->debug( "calling serializeType w/null param" );
						$xml .= $this->serializetype( $name, $type, null, $use, $enc_style );
					}
				}
			}
			else
			{
				$this->debug( "no parameters passed." );
			}
		}
		return $xml;
	}

	function serializeparameters( $operation, $direction, $parameters )
	{
		$this->debug( "in serializeParameters with operation ".$operation.", direction ".$direction." and ".count( $parameters )." param(s), and xml schema version ".$this->XMLSchemaVersion );
		if ( $direction != "input" && $direction != "output" )
		{
			$this->debug( "The value of the \\\$direction argument needs to be either \"input\" or \"output\"" );
			$this->seterror( "The value of the \\\$direction argument needs to be either \"input\" or \"output\"" );
			return false;
		}
		if ( !( $opData = $this->getoperationdata( $operation ) ) )
		{
			$this->debug( "Unable to retrieve WSDL data for operation: ".$operation );
			$this->seterror( "Unable to retrieve WSDL data for operation: ".$operation );
			return false;
		}
		$this->debug( $this->vardump( $opData ) );
		$encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/";
		if ( $direction == "input" && isset( $opData['output']['encodingStyle'] ) && $opData['output']['encodingStyle'] != $encodingStyle )
		{
			$encodingStyle = $opData['output']['encodingStyle'];
			$enc_style = $encodingStyle;
		}
		$xml = "";
		if ( isset( $opData[$direction]['parts'] ) && 0 < sizeof( $opData[$direction]['parts'] ) )
		{
			$use = $opData[$direction]['use'];
			$this->debug( "use={$use}" );
			$this->debug( "got ".count( $opData[$direction]['parts'] )." part(s)" );
			if ( is_array( $parameters ) )
			{
				$parametersArrayType = $this->isarraysimpleorstruct( $parameters );
				$this->debug( "have ".$parametersArrayType." parameters" );
				foreach ( $opData[$direction]['parts'] as $name => $type )
				{
					$this->debug( "serializing part \"".$name."\" of type \"".$type."\"" );
					if ( isset( $opData[$direction]['encodingStyle'] ) && $encodingStyle != $opData[$direction]['encodingStyle'] )
					{
						$encodingStyle = $opData[$direction]['encodingStyle'];
						$enc_style = $encodingStyle;
					}
					else
					{
						$enc_style = false;
					}
					if ( $parametersArrayType == "arraySimple" )
					{
						$p = array_shift( $parameters );
						$this->debug( "calling serializeType w/indexed param" );
						$xml .= $this->serializetype( $name, $type, $p, $use, $enc_style );
					}
					else if ( isset( $parameters[$name] ) )
					{
						$this->debug( "calling serializeType w/named param" );
						$xml .= $this->serializetype( $name, $type, $parameters[$name], $use, $enc_style );
					}
					else
					{
						$this->debug( "calling serializeType w/null param" );
						$xml .= $this->serializetype( $name, $type, null, $use, $enc_style );
					}
				}
			}
			else
			{
				$this->debug( "no parameters passed." );
			}
		}
		return $xml;
	}

	function serializetype( $name, $type, $value, $use = "encoded", $encodingStyle = false )
	{
		$this->debug( "in serializeType: {$name}, {$type}, {$value}, {$use}, {$encodingStyle}" );
		if ( $use == "encoded" && $encodingStyle )
		{
			$encodingStyle = " SOAP-ENV:encodingStyle=\"".$encodingStyle."\"";
		}
		if ( is_object( $value ) && get_class( $value ) == "soapval" )
		{
			if ( $value->type_ns )
			{
				$type = $value->type_ns.":".$value->type;
			}
			else
			{
				$type = $value->type;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -