我正在使用PHP,以前从未使用过SOAP和PHP。
我需要构建,一个Soap客户端,它正在从Soap服务器.NET Web服务中调用和检索信息。
我目前正在为荷兰卫生保健系统中的医生获取信息, .for,每个在荷兰医疗系统注册的医生,您可以从使用WSDL的SOAP web服务中检索他的信息,通过他唯一的唯一的大ID - 11位数字唯一号码)。
因此,当我调用SOAP服务器时,:(服务器的链接在下面)
一个测试网站(比如soapclinet.com)
我的XML响应是正确的,它与下面的XML完全一样,括号中是我想要在php中捕获的医生的信息。
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ListHcpApprox3Result xmlns="http://services.cibg.nl/ExternalUser">
<ListHcpApprox>
<ListHcpApprox3>
<HcpNumber>200822</HcpNumber>
<BirthSurname> [Surname of the Doctor]</BirthSurname>
<MailingName> [Mailing name of the doctor] </MailingName>
<Initial> [Initials of the doctor] </Initial>
<Gender> [Gender of the doctor] </Gender>
<ArticleRegistration>
<ArticleRegistrationExtApp>
<ArticleRegistrationNumber> [unique BIG ID] </ArticleRegistrationNumber>
<StartDate>1998-12-10T00:00:00</StartDate>
<EndDate xsi:nil="true"/>
<TypeOfSpecialismId>15</TypeOfSpecialismId>
</SpecialismExtApp>
</Specialism>
<Mention/>
<JudgmentProvision/>
<Limitation/>
</ListHcpApprox3>
</ListHcpApprox>
</ListHcpApprox3Result>
</soap:Body>
</soap:Envelope>我需要构建一个PHP页面,它将执行完全相同的SOAP调用.
wsdl文件的地址是:
webservices.cibg.nl/Ribiz/OpenbaarV2.asmx?wsdl.asmx?wsdl
soap服务器地址是: http://webservices-acc.cibg.nl/Ribiz/OpenbaarV2.asmx
soap操作如下: http://services.cibg.nl/ExternalUser/ListHcpApprox3
和我发送的SOAP消息是:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<listHcpApproxRequest xmlns="http://services.cibg.nl/ExternalUser">
<WebSite>Ribiz</WebSite>
<RegistrationNumber> [BIG ID number of the doctor] </RegistrationNumber>
</listHcpApproxRequest>
</soap:Body>
</soap:Envelope>(括号中是我们在SOAP服务器中发送的医生的大ID号)
如何将上面的SOAP操作写入PHP代码,并将我获得的作为响应的XML变量存储在PHP中?
我需要在php代码中存储的XML响应中的变量是.
<HcpNumber>200822</HcpNumber>
<BirthSurname> [Surname of the Doctor]</BirthSurname>
<MailingName> [Mailing name of the doctor] </MailingName>
<Initial> [Initials of the doctor] </Initial>
<Gender> [Gender of the doctor] </Gender> Update1: --这是var_dump的输出。其中xxxxxxx是我想要存储在php变量中的值!
object(stdClass)[2]
public 'ListHcpApprox' =>
object(stdClass)[3]
public 'ListHcpApprox3' =>
object(stdClass)[4]
public 'HcpNumber' => string 'xxxxxxxxx' (length=6)
public 'BirthSurname' => string 'xxxxxxxxxxx' (length=9)
public 'MailingName' => string 'xxxxxxxxxxxxxxxxxx' (length=18)
public 'Initial' => string 'xxxxxxxxxxxx' (length=8)
public 'Gender' => string 'x' (length=1)
public 'ArticleRegistration' =>
object(stdClass)[5]
...
public 'Specialism' =>
object(stdClass)[7]
...
public 'Mention' =>
object(stdClass)[9]
...
public 'JudgmentProvision' =>
object(stdClass)[10]
...
public 'Limitation' =>
object(stdClass)[11]
...发布于 2013-07-10 09:50:22
PHP有一个本地SoapClient类,可以轻松地调用SOAP服务。它提供了一个简单的接口,允许您对请求和响应数据使用本地PHP数组和对象,并处理SOAP信封和WSDL的复杂问题。
// create a new SoapClient and pass it the WSDL
$client = new SoapClient('http://webservices.cibg.nl/Ribiz/OpenbaarV2.asmx?WSDL');
// define the input parameters for the webservice call
$params = array('WebSite' => 'Ribiz', 'RegistrationNumber' => 'xxxxxxxxxx');
// invoke the ListHcpApprox3 method
$response = $client->ListHcpApprox3($params);
// print out the response to see its structure
var_dump($response);您可以从响应中选择以下变量:
$data = $response->ListHcpApprox->ListHcpApprox3
$HcpNumber = $data->HcpNumber;
$BirthSurname = $data->BirthSurname;
echo $HcpNumber;https://stackoverflow.com/questions/17567424
复制相似问题