0
PHPクライアントでMicrosoft .NET SOAP Webサービスによって生成されたデータセットを読み取る最も良い方法は何ですか?PHPクライアントでMicrosoft .NET SOAP Webサービスからデータセットを読み取る方法
私は、Webサービス
<?xml version="1.0" encoding="UTF-8"?>
<DataSet xmlns="http://Example/wsExchangeExample/">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="Categoria" type="xs:string" minOccurs="0" />
<xs:element name="titolo" type="xs:string" minOccurs="0" />
<xs:element name="Cognome" type="xs:string" minOccurs="0" />
<xs:element name="Nome" type="xs:string" minOccurs="0" />
<xs:element name="Cod_fisc" type="xs:string" minOccurs="0" />
<xs:element name="DIP" type="xs:dateTime" minOccurs="0" />
<xs:element name="DPI" type="xs:dateTime" minOccurs="0" />
<xs:element name="DR" type="xs:dateTime" minOccurs="0" />
<xs:element name="L_PI" type="xs:string" minOccurs="0" />
<xs:element name="N_Iscrizione" type="xs:int" minOccurs="0" />
<xs:element name="d_canc" type="xs:dateTime" minOccurs="0" />
<xs:element name="D_nas" type="xs:dateTime" minOccurs="0" />
<xs:element name="L_nas" type="xs:string" minOccurs="0" />
<xs:element name="P_nascita" type="xs:string" minOccurs="0" />
<xs:element name="Scheda" type="xs:boolean" minOccurs="0" />
<xs:element name="Note" type="xs:string" minOccurs="0" />
<xs:element name="CodIscritto" type="xs:string" minOccurs="0" />
<xs:element name="Sesso" type="xs:string" minOccurs="0" />
<xs:element name="Stato" type="xs:string" minOccurs="0" />
<xs:element name="Senatore" type="xs:boolean" minOccurs="0" />
<xs:element name="Ultrasettantenne" type="xs:boolean" minOccurs="0" />
<xs:element name="Giovane" type="xs:boolean" minOccurs="0" />
<xs:element name="Pensionato" type="xs:boolean" minOccurs="0" />
<xs:element name="Dipendente" type="xs:boolean" minOccurs="0" />
<xs:element name="Carica" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<Categoria>B</Categoria>
<titolo>Ing. Junior</titolo>
<Cognome>BLACK</Cognome>
<Nome>PETER</Nome>
<Cod_fisc>AAAAAAAAAA</Cod_fisc>
<DIP>2002-12-03T00:00:00+01:00</DIP>
<DPI>2002-12-03T00:00:00+01:00</DPI>
<L_PI>MILANO</L_PI>
<N_Iscrizione>1</N_Iscrizione>
<D_nas>1971-03-08T00:00:00+01:00</D_nas>
<L_nas>Borgo Sesia</L_nas>
<P_nascita>MI</P_nascita>
<Scheda>false</Scheda>
<CodIscritto>1B</CodIscritto>
<Sesso>1</Sesso>
<Stato>Attivo</Stato>
<Senatore>false</Senatore>
<Ultrasettantenne>false</Ultrasettantenne>
<Giovane>false</Giovane>
<Pensionato>false</Pensionato>
<Dipendente>true</Dipendente>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<Categoria>B</Categoria>
<titolo>Ing. Junior</titolo>
<Cognome>WHITE</Cognome>
<Nome>CAROL</Nome>
<Cod_fisc>XXXXXXXXX</Cod_fisc>
<DIP>2003-01-14T00:00:00+01:00</DIP>
<DPI>2003-01-14T00:00:00+01:00</DPI>
<L_PI>Como</L_PI>
<N_Iscrizione>9999</N_Iscrizione>
<D_nas>1975-03-09T00:00:00+01:00</D_nas>
<L_nas>Como</L_nas>
<Scheda>false</Scheda>
<CodIscritto>2B</CodIscritto>
<Sesso>2</Sesso>
<Stato>Attivo</Stato>
<Senatore>false</Senatore>
<Ultrasettantenne>false</Ultrasettantenne>
<Giovane>false</Giovane>
<Pensionato>false</Pensionato>
<Dipendente>false</Dipendente>
</Table>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
から次の応答を持っている私のPHPコードのこれまでのところ非常に簡単です:
/* Initialize webservice with your WSDL */
$client = new SoapClient("http://www.myurl.com/wsExchangeExample/wservice.asmx?WSDL");
/* Invoke webservice method with your parameters, in this case: Function1 */
$response = $client->__soapCall("Function1", array());
/* Print webservice response */
var_dump($response);
それはのようなものを返す:
object(stdClass)[2]
public 'Function1Result' =>
object(stdClass)[3]
public 'schema' => string '<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="Table"><xs:complexType><xs:sequence><xs:element name="Categoria" type="xs:string" minOccurs="0"/><xs:element name="titolo" type="xs:string" minOccurs="0"/><xs:element name="Cognome" type="xs:string" minOccurs="0"/>'... (length=1916)
public 'any' => string '<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><NewDataSet xmlns=""><Table diffgr:id etc. etc.
どのようにこの応答を解析することは可能ですか?私は以下を試しました:
$xml = new SimpleXMLElement($response);
しかし、私はエラーを返します($応答は文字列ではありません)。 これは、PHPでこのタスクを実行する最良の方法ですか?
は 'SimpleXMLElement'の代わりに、' $のresponse'にhttp://php.net/manual/en/soapclient.getlastresponse.phpを試してみてください – Edwin