📄 nusoap.php
字号:
return false;
}
function getprefixfromnamespace( $ns )
{
foreach ( $this->namespaces as $p => $n )
{
if ( $ns == $n || $ns == $p )
{
$this->usedNamespaces[$p] = $n;
return $p;
}
}
return false;
}
function vardump( $data )
{
ob_start( );
var_dump( $data );
$ret_val = ob_get_contents( );
ob_end_clean( );
return $ret_val;
}
}
class soap_fault extends nusoap_base
{
var $title = "NuSOAP";
var $version = "0.6.7";
var $revision = "\$Revision: 1.72 \$";
var $error_str = false;
var $debug_str = "";
var $charencoding = true;
var $XMLSchemaVersion = "http://www.w3.org/2001/XMLSchema";
var $soap_defencoding = "gb2312";
var $namespaces = array
(
"SOAP-ENV" => "http://schemas.xmlsoap.org/soap/envelope/",
"xsd" => "http://www.w3.org/2001/XMLSchema",
"xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"SOAP-ENC" => "http://schemas.xmlsoap.org/soap/encoding/",
"si" => "http://soapinterop.org/xsd"
);
var $usedNamespaces = array( );
var $typemap = array
(
"http://www.w3.org/2001/XMLSchema" => array
(
"string" => "string",
"boolean" => "boolean",
"float" => "double",
"double" => "double",
"decimal" => "double",
"duration" => "",
"dateTime" => "string",
"time" => "string",
"date" => "string",
"gYearMonth" => "",
"gYear" => "",
"gMonthDay" => "",
"gDay" => "",
"gMonth" => "",
"hexBinary" => "string",
"base64Binary" => "string",
"normalizedString" => "string",
"token" => "string",
"language" => "",
"NMTOKEN" => "",
"NMTOKENS" => "",
"Name" => "",
"NCName" => "",
"ID" => "",
"IDREF" => "",
"IDREFS" => "",
"ENTITY" => "",
"ENTITIES" => "",
"integer" => "integer",
"nonPositiveInteger" => "integer",
"negativeInteger" => "integer",
"long" => "integer",
"int" => "integer",
"short" => "integer",
"byte" => "integer",
"nonNegativeInteger" => "integer",
"unsignedLong" => "",
"unsignedInt" => "",
"unsignedShort" => "",
"unsignedByte" => "",
"positiveInteger" => ""
),
"http://www.w3.org/1999/XMLSchema" => array
(
"i4" => "",
"int" => "integer",
"boolean" => "boolean",
"string" => "string",
"double" => "double",
"float" => "double",
"dateTime" => "string",
"timeInstant" => "string",
"base64Binary" => "string",
"base64" => "string",
"ur-type" => "array"
),
"http://soapinterop.org/xsd" => array
(
"SOAPStruct" => "struct"
),
"http://schemas.xmlsoap.org/soap/encoding/" => array
(
"base64" => "string",
"array" => "array",
"Array" => "array"
),
"http://xml.apache.org/xml-soap" => array
(
0 => "Map"
)
);
var $xmlEntities = array
(
"quot" => "\"",
"amp" => "&",
"lt" => "<",
"gt" => ">",
"apos" => "'"
);
var $faultcode;
var $faultactor;
var $faultstring;
var $faultdetail;
function soap_fault( $faultcode, $faultactor = "", $faultstring = "", $faultdetail = "" )
{
$this->faultcode = $faultcode;
$this->faultactor = $faultactor;
$this->faultstring = $faultstring;
$this->faultdetail = $faultdetail;
}
function serialize( )
{
$ns_string = "";
foreach ( $this->namespaces as $k => $v )
{
$ns_string .= "\n xmlns:{$k}=\"{$v}\"";
}
$return_msg = "<?xml version=\"1.0\" encoding=\"".$this->soap_defencoding."\"?>"."<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"".$ns_string.">\n"."<SOAP-ENV:Body>"."<SOAP-ENV:Fault>"."<faultcode>".$this->expandentities( $this->faultcode )."</faultcode>"."<faultactor>".$this->expandentities( $this->faultactor )."</faultactor>"."<faultstring>".$this->expandentities( $this->faultstring )."</faultstring>"."<detail>".$this->serialize_val( $this->faultdetail )."</detail>"."</SOAP-ENV:Fault>"."</SOAP-ENV:Body>"."</SOAP-ENV:Envelope>";
return $return_msg;
}
}
class xmlschema extends nusoap_base
{
var $title = "NuSOAP";
var $version = "0.6.7";
var $revision = "\$Revision: 1.72 \$";
var $error_str = false;
var $debug_str = "";
var $charencoding = true;
var $XMLSchemaVersion = "http://www.w3.org/2001/XMLSchema";
var $soap_defencoding = "gb2312";
var $namespaces = array
(
"SOAP-ENV" => "http://schemas.xmlsoap.org/soap/envelope/",
"xsd" => "http://www.w3.org/2001/XMLSchema",
"xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"SOAP-ENC" => "http://schemas.xmlsoap.org/soap/encoding/",
"si" => "http://soapinterop.org/xsd"
);
var $usedNamespaces = array( );
var $typemap = array
(
"http://www.w3.org/2001/XMLSchema" => array
(
"string" => "string",
"boolean" => "boolean",
"float" => "double",
"double" => "double",
"decimal" => "double",
"duration" => "",
"dateTime" => "string",
"time" => "string",
"date" => "string",
"gYearMonth" => "",
"gYear" => "",
"gMonthDay" => "",
"gDay" => "",
"gMonth" => "",
"hexBinary" => "string",
"base64Binary" => "string",
"normalizedString" => "string",
"token" => "string",
"language" => "",
"NMTOKEN" => "",
"NMTOKENS" => "",
"Name" => "",
"NCName" => "",
"ID" => "",
"IDREF" => "",
"IDREFS" => "",
"ENTITY" => "",
"ENTITIES" => "",
"integer" => "integer",
"nonPositiveInteger" => "integer",
"negativeInteger" => "integer",
"long" => "integer",
"int" => "integer",
"short" => "integer",
"byte" => "integer",
"nonNegativeInteger" => "integer",
"unsignedLong" => "",
"unsignedInt" => "",
"unsignedShort" => "",
"unsignedByte" => "",
"positiveInteger" => ""
),
"http://www.w3.org/1999/XMLSchema" => array
(
"i4" => "",
"int" => "integer",
"boolean" => "boolean",
"string" => "string",
"double" => "double",
"float" => "double",
"dateTime" => "string",
"timeInstant" => "string",
"base64Binary" => "string",
"base64" => "string",
"ur-type" => "array"
),
"http://soapinterop.org/xsd" => array
(
"SOAPStruct" => "struct"
),
"http://schemas.xmlsoap.org/soap/encoding/" => array
(
"base64" => "string",
"array" => "array",
"Array" => "array"
),
"http://xml.apache.org/xml-soap" => array
(
0 => "Map"
)
);
var $xmlEntities = array
(
"quot" => "\"",
"amp" => "&",
"lt" => "<",
"gt" => ">",
"apos" => "'"
);
var $schema = "";
var $xml = "";
var $enclosingNamespaces;
var $schemaInfo = array( );
var $schemaTargetNamespace = "";
var $attributes = array( );
var $complexTypes = array( );
var $currentComplexType = false;
var $elements = array( );
var $currentElement = false;
var $simpleTypes = array( );
var $currentSimpleType = false;
var $imports = array( );
var $parser;
var $position = 0;
var $depth = 0;
var $depth_array = array( );
var $message = array( );
var $defaultNamespace = array( );
function xmlschema( $schema = "", $xml = "", $namespaces = array( ) )
{
$this->debug( "xmlschema class instantiated, inside constructor" );
$this->schema = $schema;
$this->xml = $xml;
$this->enclosingNamespaces = $namespaces;
$this->namespaces = array_merge( $this->namespaces, $namespaces );
if ( $schema != "" )
{
$this->debug( "initial schema file: ".$schema );
$this->parsefile( $schema, "schema" );
}
if ( $xml != "" )
{
$this->debug( "initial xml file: ".$xml );
$this->parsefile( $xml, "xml" );
}
}
function parsefile( $xml, $type )
{
if ( $xml != "" )
{
$xmlStr = @join( "", @file( $xml ) );
if ( $xmlStr == "" )
{
$msg = "Error reading XML from ".$xml;
$this->seterror( $msg );
$this->debug( $msg );
return false;
}
else
{
$this->debug( "parsing {$xml}" );
$this->parsestring( $xmlStr, $type );
$this->debug( "done parsing {$xml}" );
return true;
}
}
return false;
}
function parsestring( $xml, $type )
{
if ( $xml != "" )
{
$this->parser = xml_parser_create( );
xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
xml_set_object( $this->parser, $this );
if ( $type == "schema" )
{
xml_set_element_handler( $this->parser, "schemaStartElement", "schemaEndElement" );
xml_set_character_data_handler( $this->parser, "schemaCharacterData" );
}
else if ( $type == "xml" )
{
xml_set_element_handler( $this->parser, "xmlStartElement", "xmlEndElement" );
xml_set_character_data_handler( $this->parser, "xmlCharacterData" );
}
if ( !xml_parse( $this->parser, $xml, true ) )
{
$errstr = sprintf( "XML error parsing XML schema on line %d: %s", xml_get_current_line_number( $this->parser ), xml_error_string( xml_get_error_code( $this->parser ) ) );
$this->debug( $errstr );
$this->debug( "XML payload:\n".$xml );
$this->seterror( $errstr );
}
xml_parser_free( $this->parser );
}
else
{
$this->debug( "no xml passed to parseString()!!" );
$this->seterror( "no xml passed to parseString()!!" );
}
}
function schemastartelement( $parser, $name, $attrs )
{
$pos = $this->position++;
$depth = $this->depth++;
$this->depth_array[$depth] = $pos;
$this->message[$pos] = array( "cdata" => "" );
if ( 0 < $depth )
{
$this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
}
else
{
$this->defaultNamespace[$pos] = false;
}
if ( $prefix = $this->getprefix( $name ) )
{
$name = $this->getlocalpart( $name );
}
else
{
$prefix = "";
}
if ( 0 < count( $attrs ) )
{
foreach ( $attrs as $k => $v )
{
if ( ereg( "^xmlns", $k ) )
{
if ( $ns_prefix = substr( strrchr( $k, ":" ), 1 ) )
{
$this->namespaces[$ns_prefix] = $v;
}
else
{
$this->defaultNamespace[$pos] = $v;
if ( !$this->getprefixfromnamespace( $v ) )
{
$this->namespaces["ns".( count( $this->namespaces ) + 1 )] = $v;
}
}
if ( $v == "http://www.w3.org/2001/XMLSchema" || $v == "http://www.w3.org/1999/XMLSchema" )
{
$this->XMLSchemaVersion = $v;
$this->namespaces['xsi'] = $v."-instance";
}
}
}
foreach ( $attrs as $k => $v )
{
$k = strpos( $k, ":" ) ? $this->expandqname( $k ) : $k;
$v = strpos( $v, ":" ) ? $this->expandqname( $v ) : $v;
$eAttrs[$k] = $v;
}
$attrs = $eAttrs;
}
else
{
$attrs = array( );
}
switch ( $name )
{
case "all" :
case "choice" :
case "sequence" :
$this->complexTypes[$this->currentComplexType]['compositor'] = $name;
if ( !( $name == "all" || $name == "sequence" ) )
{
break;
}
$this->complexTypes[$this->currentComplexType]['phpType'] = "struct";
break;
case "attribute" :
$this->xdebug( "parsing attribute ".$this->vardump( $attrs ) );
if ( isset( $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] ) )
{
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
if ( !strpos( $v, ":" ) && $this->defaultNamespace[$pos] )
{
$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos].":".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
}
}
if ( isset( $attrs['name'] ) )
{
$this->attributes[$attrs['name']] = $attrs;
$aname = $attrs['name'];
}
else if ( isset( $attrs['ref'] ) && $attrs['ref'] == "http://schemas.xmlsoap.org/soap/encoding/:arrayType" )
{
if ( isset( $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] ) )
{
$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
}
else
{
$aname = "";
}
}
else if ( isset( $attrs['ref'] ) )
{
$aname = $attrs['ref'];
$this->attributes[$attrs['ref']] = $attrs;
}
if ( isset( $this->currentComplexType ) )
{
$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
}
else if ( isset( $this->currentElement ) )
{
$this->elements[$this->currentElement]['attrs'][$aname] = $attrs;
}
if ( !( isset( $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] ) || $this->getlocalpart( $aname ) == "arrayType" ) )
{
break;
}
$this->complexTypes[$this->currentComplexType]['phpType'] = "array";
$prefix = $this->getprefix( $aname );
if ( isset( $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] ) )
{
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
}
else
{
$v = "";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -