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

📄 class.soap_server.php

📁 学校网站源码http://您的网址/admin/admin_login.asp 默认登录用户:admin 默认登录密码:admin
💻 PHP
📖 第 1 页 / 共 2 页
字号:
			}
			else
			{
				$this->debug( "calling method using call_user_func_array()" );
				$this->methodreturn = call_user_func_array( "{$this->methodname}", $this->methodparams );
			}
		}
		else
		{
			$this->debug( "calling {$this->methodname} w/ no params" );
			$m = $this->methodname;
			$this->methodreturn = @$m( );
		}
		$this->debug( "methodreturn var dump".$this->vardump( $this->methodreturn ) );
		$this->debug( "leaving invoke_method: called method {$this->methodname}, received {$this->methodreturn} of type ".gettype( $this->methodreturn ) );
	}

	function serialize_return( )
	{
		$this->debug( "Entering serialize_return" );
		if ( isset( $this->methodreturn ) && ( $this->methodreturn != "" || is_bool( $this->methodreturn ) ) )
		{
			if ( get_class( $this->methodreturn ) == "soap_fault" )
			{
				$this->debug( "got a fault object from method" );
				$this->fault = $this->methodreturn;
				return;
			}
			else if ( $this->methodreturnisliteralxml )
			{
				$return_val = $this->methodreturn;
			}
			else
			{
				$this->debug( "got a(n) ".gettype( $this->methodreturn )." from method" );
				$this->debug( "serializing return value" );
				if ( $this->wsdl )
				{
					if ( 1 < sizeof( $this->opData['output']['parts'] ) )
					{
						$opParams = $this->methodreturn;
					}
					else
					{
						$opParams = array(
							$this->methodreturn
						);
					}
					$return_val = $this->wsdl->serializerpcparameters( $this->methodname, "output", $opParams );
					if ( $errstr = $this->wsdl->geterror( ) )
					{
						$this->debug( "got wsdl error: ".$errstr );
						$this->fault( "Server", "got wsdl error: ".$errstr );
						return;
					}
				}
				else
				{
					$return_val = $this->serialize_val( $this->methodreturn, "return" );
				}
			}
			$this->debug( "return val: ".$this->vardump( $return_val ) );
		}
		else
		{
			$return_val = "";
			$this->debug( "got no response from method" );
		}
		$this->debug( "serializing response" );
		if ( $this->wsdl )
		{
			if ( $this->opData['style'] == "rpc" )
			{
				$payload = "<ns1:".$this->methodname."Response xmlns:ns1=\"".$this->methodURI."\">".$return_val."</ns1:".$this->methodname."Response>";
			}
			else
			{
				$payload = $return_val;
			}
		}
		else
		{
			$payload = "<ns1:".$this->methodname."Response xmlns:ns1=\"".$this->methodURI."\">".$return_val."</ns1:".$this->methodname."Response>";
		}
		$this->result = "successful";
		if ( $this->wsdl )
		{
			$this->debug( "WSDL debug data:\n".$this->wsdl->debug_str );
			$this->responseSOAP = $this->serializeenvelope( $payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'] );
		}
		else
		{
			$this->responseSOAP = $this->serializeenvelope( $payload, $this->responseHeaders );
		}
		$this->debug( "Leaving serialize_return" );
	}

	function send_response( )
	{
		$this->debug( "Enter send_response" );
		if ( $this->fault )
		{
			$payload = $this->fault->serialize( );
			$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
			$this->outgoing_headers[] = "Status: 500 Internal Server Error";
		}
		else
		{
			$payload = $this->responseSOAP;
		}
		if ( isset( $this->debug_flag ) && $this->debug_flag )
		{
			while ( strpos( $this->debug_str, "--" ) )
			{
				$this->debug_str = str_replace( "--", "- -", $this->debug_str );
			}
			$payload .= "<!--\n".$this->debug_str."\n-->";
		}
		$this->outgoing_headers[] = "Server: {$this->title} Server v{$this->version}";
		ereg( "\\\$Revisio"."n: ([^ ]+)", $this->revision, $rev );
		$this->outgoing_headers[] = "X-SOAP-Server: {$this->title}/{$this->version} (".$rev[1].")";
		$this->outgoing_headers[] = "Content-Type: text/xml; charset={$this->soap_defencoding}";
		if ( 1024 < strlen( $payload ) && isset( $this->headers ) && isset( $this->headers['Accept-Encoding'] ) )
		{
			if ( strstr( $this->headers['Accept-Encoding'], "deflate" ) )
			{
				if ( function_exists( "gzcompress" ) )
				{
					if ( isset( $this->debug_flag ) && $this->debug_flag )
					{
						$payload .= "<!-- Content being deflated -->";
					}
					$this->outgoing_headers[] = "Content-Encoding: deflate";
					$payload = gzcompress( $payload );
				}
				else if ( isset( $this->debug_flag ) && $this->debug_flag )
				{
					$payload .= "<!-- Content will not be deflated: no gzcompress -->";
				}
			}
			else if ( strstr( $this->headers['Accept-Encoding'], "gzip" ) )
			{
				if ( function_exists( "gzencode" ) )
				{
					if ( isset( $this->debug_flag ) && $this->debug_flag )
					{
						$payload .= "<!-- Content being gzipped -->";
					}
					$this->outgoing_headers[] = "Content-Encoding: gzip";
					$payload = gzencode( $payload );
				}
				else if ( isset( $this->debug_flag ) && $this->debug_flag )
				{
					$payload .= "<!-- Content will not be gzipped: no gzencode -->";
				}
			}
		}
		$this->outgoing_headers[] = "Content-Length: ".strlen( $payload );
		reset( $this->outgoing_headers );
		foreach ( $this->outgoing_headers as $hdr )
		{
			header( $hdr, false );
		}
		$this->response = join( "\r\n", $this->outgoing_headers )."\r\n".$payload;
		print $payload;
	}

	function verify_method( $operation, $request )
	{
		if ( isset( $this->wsdl ) && is_object( $this->wsdl ) )
		{
			if ( $this->wsdl->getoperationdata( $operation ) )
			{
				return true;
			}
		}
		else if ( isset( $this->operations[$operation] ) )
		{
			return true;
		}
		return false;
	}

	function add_to_map( $methodname, $in, $out )
	{
		$this->operations[$methodname] = array(
			"name" => $methodname,
			"in" => $in,
			"out" => $out
		);
	}

	function register( $name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = "" )
	{
		if ( $this->externalWSDLURL )
		{
			exit( "You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL." );
		}
		if ( false == $in )
		{
		}
		if ( false == $out )
		{
		}
		if ( false == $namespace )
		{
		}
		if ( false == $soapaction )
		{
			$SERVER_NAME = isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : $GLOBALS['SERVER_NAME'];
			$SCRIPT_NAME = isset( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['SCRIPT_NAME'] : $GLOBALS['SCRIPT_NAME'];
			$soapaction = "http://{$SERVER_NAME}{$SCRIPT_NAME}/{$name}";
		}
		if ( false == $style )
		{
			$style = "rpc";
		}
		if ( false == $use )
		{
			$use = "encoded";
		}
		$this->operations[$name] = array(
			"name" => $name,
			"in" => $in,
			"out" => $out,
			"namespace" => $namespace,
			"soapaction" => $soapaction,
			"style" => $style
		);
		if ( $this->wsdl )
		{
			$this->wsdl->addoperation( $name, $in, $out, $namespace, $soapaction, $style, $use, $documentation );
		}
		return true;
	}

	function fault( $faultcode, $faultstring, $faultactor = "", $faultdetail = "" )
	{
		$this->fault = new soap_fault( $faultcode, $faultactor, $faultstring, $faultdetail );
	}

	function webdescription( )
	{
		$b = "\n\t\t<html><head><title>NuSOAP: ".$this->wsdl->serviceName."</title>\n\t\t<style type=\"text/css\">\n\t\t    body    { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }\n\t\t    p       { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }\n\t\t    pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}\n\t\t    ul      { margin-top: 10px; margin-left: 20px; }\n\t\t    li      { list-style-type: none; margin-top: 10px; color: #000000; }\n\t\t    .content{\n\t\t\tmargin-left: 0px; padding-bottom: 2em; }\n\t\t    .nav {\n\t\t\tpadding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;\n\t\t\tmargin-top: 10px; margin-left: 0px; color: #000000;\n\t\t\tbackground-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }\n\t\t    .title {\n\t\t\tfont-family: arial; font-size: 26px; color: #ffffff;\n\t\t\tbackground-color: #999999; width: 105%; margin-left: 0px;\n\t\t\tpadding-top: 10px; padding-bottom: 10px; padding-left: 15px;}\n\t\t    .hidden {\n\t\t\tposition: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;\n\t\t\tfont-family: arial; overflow: hidden; width: 600;\n\t\t\tpadding: 20px; font-size: 10px; background-color: #999999;\n\t\t\tlayer-background-color:#FFFFFF; }\n\t\t    a,a:active  { color: charcoal; font-weight: bold; }\n\t\t    a:visited   { color: #666666; font-weight: bold; }\n\t\t    a:hover     { color: cc3300; font-weight: bold; }\n\t\t</style>\n\t\t<script language=\"JavaScript\" type=\"text/javascript\">\n\t\t<!--\n\t\t// POP-UP CAPTIONS...\n\t\tfunction lib_bwcheck(){ //Browsercheck (needed)\n\t\t    this.ver=navigator.appVersion\n\t\t    this.agent=navigator.userAgent\n\t\t    this.dom=document.getElementById?1:0\n\t\t    this.opera5=this.agent.indexOf(\"Opera 5\")>-1\n\t\t    this.ie5=(this.ver.indexOf(\"MSIE 5\")>-1 && this.dom && !this.opera5)?1:0;\n\t\t    this.ie6=(this.ver.indexOf(\"MSIE 6\")>-1 && this.dom && !this.opera5)?1:0;\n\t\t    this.ie4=(document.all && !this.dom && !this.opera5)?1:0;\n\t\t    this.ie=this.ie4||this.ie5||this.ie6\n\t\t    this.mac=this.agent.indexOf(\"Mac\")>-1\n\t\t    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;\n\t\t    this.ns4=(document.layers && !this.dom)?1:0;\n\t\t    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)\n\t\t    return this\n\t\t}\n\t\tvar bw = new lib_bwcheck()\n\t\t//Makes crossbrowser object.\n\t\tfunction makeObj(obj){\n\t\t    this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;\n\t\t    if(!this.evnt) return false\n\t\t    this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;\n\t\t    this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;\n\t\t    this.writeIt=b_writeIt;\n\t\t    return this\n\t\t}\n\t\t// A unit of measure that will be added when setting the position of a layer.\n\t\t//var px = bw.ns4||window.opera?\"\":\"px\";\n\t\tfunction b_writeIt(text){\n\t\t    if (bw.ns4){this.wref.write(text);this.wref.close()}\n\t\t    else this.wref.innerHTML = text\n\t\t}\n\t\t//Shows the messages\n\t\tvar oDesc;\n\t\tfunction popup(divid){\n\t\t    if(oDesc = new makeObj(divid)){\n\t\t\toDesc.css.visibility = \"visible\"\n\t\t    }\n\t\t}\n\t\tfunction popout(){ // Hides message\n\t\t    if(oDesc) oDesc.css.visibility = \"hidden\"\n\t\t}\n\t\t//-->\n\t\t</script>\n\t\t</head>\n\t\t<body>\n\t\t<div class=content>\n\t\t\t<br><br>\n\t\t\t<div class=title>".$this->wsdl->serviceName."</div>\n\t\t\t<div class=nav>\n\t\t\t\t<p>View the <a href=\"".( isset( $GLOBALS['PHP_SELF'] ) ? $GLOBALS['PHP_SELF'] : $_SERVER['PHP_SELF'] )."?wsdl\">WSDL</a> for the service.\n\t\t\t\tClick on an operation name to view it&apos;s details.</p>\n\t\t\t\t<ul>";
		foreach ( $this->wsdl->getoperations( ) as $op => $data )
		{
			$b .= "<li><a href='#' onclick=\"popup('{$op}')\">{$op}</a></li>";
			$b .= "<div id='{$op}' class='hidden'>\n\t\t\t\t    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
			foreach ( $data as $donnie => $marie )
			{
				if ( $donnie == "input" || $donnie == "output" )
				{
					$b .= "<font color='white'>".ucfirst( $donnie ).":</font><br>";
					foreach ( $marie as $captain => $tenille )
					{
						if ( $captain == "parts" )
						{
							$b .= "&nbsp;&nbsp;{$captain}:<br>";
							foreach ( $tenille as $joanie => $chachi )
							{
								$b .= "&nbsp;&nbsp;&nbsp;&nbsp;{$joanie}: {$chachi}<br>";
							}
						}
						else
						{
							$b .= "&nbsp;&nbsp;{$captain}: {$tenille}<br>";
						}
					}
				}
				else
				{
					$b .= "<font color='white'>".ucfirst( $donnie ).":</font> {$marie}<br>";
				}
			}
			$b .= "</div>";
		}
		$b .= "\n\t\t\t\t<ul>\n\t\t\t</div>\n\t\t</div></body></html>";
		return $b;
	}

	function configurewsdl( $serviceName, $namespace = false, $endpoint = false, $style = "rpc", $transport = "http://schemas.xmlsoap.org/soap/http", $schemaTargetNamespace = false )
	{
		$SERVER_NAME = isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : $GLOBALS['SERVER_NAME'];
		$SERVER_PORT = isset( $_SERVER['SERVER_PORT'] ) ? $_SERVER['SERVER_PORT'] : $GLOBALS['SERVER_PORT'];
		if ( $SERVER_PORT == 80 )
		{
			$SERVER_PORT = "";
		}
		else
		{
			$SERVER_PORT = ":".$SERVER_PORT;
		}
		$SCRIPT_NAME = isset( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['SCRIPT_NAME'] : $GLOBALS['SCRIPT_NAME'];
		if ( false == $namespace )
		{
			$namespace = "http://{$SERVER_NAME}/soap/{$serviceName}";
		}
		if ( false == $endpoint )
		{
			if ( isset( $_SERVER['HTTPS'] ) )
			{
				$HTTPS = $_SERVER['HTTPS'];
			}
			else if ( isset( $GLOBALS['HTTPS'] ) )
			{
				$HTTPS = $GLOBALS['HTTPS'];
			}
			else
			{
				$HTTPS = "0";
			}
			if ( $HTTPS == "1" || $HTTPS == "on" )
			{
				$SCHEME = "https";
			}
			else
			{
				$SCHEME = "http";
			}
			$endpoint = "{$SCHEME}://{$SERVER_NAME}{$SERVER_PORT}{$SCRIPT_NAME}";
		}
		if ( false == $schemaTargetNamespace )
		{
			$schemaTargetNamespace = $namespace;
		}
		$this->wsdl = new wsdl( );
		$this->wsdl->serviceName = $serviceName;
		$this->wsdl->endpoint = $endpoint;
		$this->wsdl->namespaces['tns'] = $namespace;
		$this->wsdl->namespaces['soap'] = "http://schemas.xmlsoap.org/wsdl/soap/";
		$this->wsdl->namespaces['wsdl'] = "http://schemas.xmlsoap.org/wsdl/";
		if ( $schemaTargetNamespace != $namespace )
		{
			$this->wsdl->namespaces['types'] = $schemaTargetNamespace;
		}
		$this->wsdl->schemas[$schemaTargetNamespace][0] = new xmlschema( "", "", $this->wsdl->namespaces );
		$this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
		$this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array(
			"location" => "",
			"loaded" => true
		);
		$this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array(
			"location" => "",
			"loaded" => true
		);
		$this->wsdl->bindings[$serviceName."Binding"] = array(
			"name" => $serviceName."Binding",
			"style" => $style,
			"transport" => $transport,
			"portType" => $serviceName."PortType"
		);
		$this->wsdl->ports[$serviceName."Port"] = array(
			"binding" => $serviceName."Binding",
			"location" => $endpoint,
			"bindingType" => "http://schemas.xmlsoap.org/wsdl/soap/"
		);
	}

}

?>

⌨️ 快捷键说明

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