写了简单的列子 结果报错 求高手帮看看。 在线等。 谢谢 了
我用 Apache 是不是少安了东西 提示错误是
Warning: SoapClient::SoapClient(http://192.168.0.23/jiekou/passport.wsdl) [function.SoapClient-SoapClient]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in F:\AppServ\www\ceshi\client.php on line 2Warning: SoapClient::SoapClient() [function.SoapClient-SoapClient]: I/O warning : failed to load external entity "http://192.168.0.23/jiekou/passport.wsdl" in F:\AppServ\www\ceshi\client.php on line 2Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://192.168.0.23/jiekou/passport.wsdl' in F:\AppServ\www\ceshi\client.php on line 2
代码如下
Passport.php
<?php
class Passport {
const E_USERNAME_INVALID = 1;
public $username;
public $passwd;
public $emai;
public $verifycode;
/**
* user register service
*
* @param string $username
* @param string $passwd
* @param string $email
* @param string $verifycode
*
* @return boolean
*/
public function register($username, $passwd, $email, $verifycode){
// here is register code
return $username. "\n" .
$passwd . "\n" .
$email . "\n" .
$verifycode;
}
}
?>
客户端
client.php
<?php
$client = new SoapClient("http://192.168.0.23/jiekou/passport.wsdl", array("trace"=>1,"exceptions"=>0,"soap_version" => SOAP_1_2));
$result = $client->register('hezhiqiang','loveit','[email protected]','H6mSkD');
var_dump($result);
?>
服务端
server.php
<?php
require_once 'Passport.php';
$server = new SoapServer(
"http://192.168.0.23/jiekou/passport.wsdl"
,array(
'encoding'=>'utf-8',
'soap_version' => SOAP_1_2,
'uri' => 'Passport',
'style' => SOAP_RPC,
'use' => SOAP_LITERAL)
);
$server->setClass('Passport');
$server->handle();
?>passport.wsdl zend studio 生成
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/passport/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="passport" targetNamespace="http://www.example.org/passport/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/passport/">
<xsd:element name="register">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="registerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="registerRequest">
<wsdl:part name="username" type="xsd:string"/>
<wsdl:part name="passwd" type="xsd:string"></wsdl:part>
<wsdl:part name="email" type="xsd:string"></wsdl:part>
<wsdl:part name="verifycode" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="registerResponse">
<wsdl:part name="registerreturn" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="passport">
<wsdl:operation name="register">
<wsdl:input message="tns:registerRequest"/>
<wsdl:output message="tns:registerResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="passportSOAP" type="tns:passport"> <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="register"> <soap:operation
soapAction="http://www.example.org/passport/register" />
<wsdl:input> <soap:body use="literal" />
</wsdl:input>
<wsdl:output> <soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="passport">
<wsdl:port binding="tns:passportSOAP" name="passportSOAP">
<soap:address location="http://192.168.0.23/jiekou/server.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我用 Apache 是不是少安了东西 提示错误是
Warning: SoapClient::SoapClient(http://192.168.0.23/jiekou/passport.wsdl) [function.SoapClient-SoapClient]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in F:\AppServ\www\ceshi\client.php on line 2Warning: SoapClient::SoapClient() [function.SoapClient-SoapClient]: I/O warning : failed to load external entity "http://192.168.0.23/jiekou/passport.wsdl" in F:\AppServ\www\ceshi\client.php on line 2Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://192.168.0.23/jiekou/passport.wsdl' in F:\AppServ\www\ceshi\client.php on line 2
代码如下
Passport.php
<?php
class Passport {
const E_USERNAME_INVALID = 1;
public $username;
public $passwd;
public $emai;
public $verifycode;
/**
* user register service
*
* @param string $username
* @param string $passwd
* @param string $email
* @param string $verifycode
*
* @return boolean
*/
public function register($username, $passwd, $email, $verifycode){
// here is register code
return $username. "\n" .
$passwd . "\n" .
$email . "\n" .
$verifycode;
}
}
?>
客户端
client.php
<?php
$client = new SoapClient("http://192.168.0.23/jiekou/passport.wsdl", array("trace"=>1,"exceptions"=>0,"soap_version" => SOAP_1_2));
$result = $client->register('hezhiqiang','loveit','[email protected]','H6mSkD');
var_dump($result);
?>
服务端
server.php
<?php
require_once 'Passport.php';
$server = new SoapServer(
"http://192.168.0.23/jiekou/passport.wsdl"
,array(
'encoding'=>'utf-8',
'soap_version' => SOAP_1_2,
'uri' => 'Passport',
'style' => SOAP_RPC,
'use' => SOAP_LITERAL)
);
$server->setClass('Passport');
$server->handle();
?>passport.wsdl zend studio 生成
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/passport/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="passport" targetNamespace="http://www.example.org/passport/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/passport/">
<xsd:element name="register">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="registerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="registerRequest">
<wsdl:part name="username" type="xsd:string"/>
<wsdl:part name="passwd" type="xsd:string"></wsdl:part>
<wsdl:part name="email" type="xsd:string"></wsdl:part>
<wsdl:part name="verifycode" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="registerResponse">
<wsdl:part name="registerreturn" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="passport">
<wsdl:operation name="register">
<wsdl:input message="tns:registerRequest"/>
<wsdl:output message="tns:registerResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="passportSOAP" type="tns:passport"> <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="register"> <soap:operation
soapAction="http://www.example.org/passport/register" />
<wsdl:input> <soap:body use="literal" />
</wsdl:input>
<wsdl:output> <soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="passport">
<wsdl:port binding="tns:passportSOAP" name="passportSOAP">
<soap:address location="http://192.168.0.23/jiekou/server.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
string(47) "hezhiqiang loveit [email protected] H6mSkD"当然测试时修改了 192.168.0.23/jiekou 为我的 ip/路径
怎么我的就不行呢