我正在使用PHP並從未使用過SOAP和PHP。如何製作PHP SOAP客戶端並在php變量中存儲結果xml
我需要建立一個肥皂PHP客戶被調用,並從 SOAP服務器.NET Web服務檢索信息。
我目前正在努力讓信息在荷蘭保健體制 醫生。對於每艘在醫療保健系統的荷蘭註冊的醫生,你可以通過他的獨特唯一BIG ID檢索 他的信息 - 使用WSDL從SOAP web服務獲得的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>
(括號內是醫生的BIG ID號,我們在SOAP服務器發送)
哪有我將上面的SOAP動作寫入PHP代碼中,並將PHP中存儲的XML變量存儲爲響應?
在XML響應,我需要在PHP代碼來存儲變量是這些...
<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]
...
它的工作!但我將結果作爲plein文本。我可以在代碼中添加一些東西,它會將var_dump($ response)分配給幾個php變量嗎? – kost
是的var_dump輸出對象作爲調試文本,所以你可以看到結構。用var_dump輸出更新問題,然後我可以告訴你如何獲取變量。 – MrCode
我剛剛更新了這個問題!感謝您的幫助! – kost