PHP « PHP SOAP: как передать параметры XML?
При создании запроса к серверу создаю XML с помощью массивов:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$request = array(
'WEB' => array(
'XML1' => 'row1',
'XML2' => array(
'row2_1' => 1,
'row2_2' => 0,
'row2_3' => 'row2_3',
'row2_4' => 'row2_4',
'row2_5' => 0,
'row2_6' => 'row2_6'
)
)
);
Но у самого верхнего узла есть параметры, это выглядит так:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .xml.geshi_code {font-family:monospace;} .xml.geshi_code .imp {font-weight: bold; color: red;} .xml.geshi_code .es0 {color: #000099; font-weight: bold;} .xml.geshi_code .br0 {color: #66cc66;} .xml.geshi_code .sy0 {color: #66cc66;} .xml.geshi_code .st0 {color: #ff0000;} .xml.geshi_code .sc-1 {color: #808080; font-style: italic;} .xml.geshi_code .sc0 {color: #00bbdd;} .xml.geshi_code .sc1 {color: #ddbb00;} .xml.geshi_code .sc2 {color: #339933;} .xml.geshi_code .sc3 {color: #009900;} .xml.geshi_code .re0 {color: #000066;} .xml.geshi_code .re1 {color: #000000; font-weight: bold;} .xml.geshi_code .re2 {color: #000000; font-weight: bold;} .xml.geshi_code span.xtra { display:block; }
<?xml version="1.0" encoding="windows-1251"?>
<WEB a="1" c="1">
... тут остальной XML
</WEB>
Как правильно написать SOAP request, чтобы передались эти параметры a и c?
UPD 1: все, что есть - WSDL и пример запроса в виде готового XML.
Я уже попробовала вот это: http://www.urdalen.no/wsdl2php/index.php
Получила на выходе класс. Но как работать дальше с этим классом - непонятно, потому что тот пример, который по ссылке выше - уже недоступен.
Вот WSDL (реальные адреса заменены на server1 и server2):
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .xml.geshi_code {font-family:monospace;} .xml.geshi_code .imp {font-weight: bold; color: red;} .xml.geshi_code .es0 {color: #000099; font-weight: bold;} .xml.geshi_code .br0 {color: #66cc66;} .xml.geshi_code .sy0 {color: #66cc66;} .xml.geshi_code .st0 {color: #ff0000;} .xml.geshi_code .sc-1 {color: #808080; font-style: italic;} .xml.geshi_code .sc0 {color: #00bbdd;} .xml.geshi_code .sc1 {color: #ddbb00;} .xml.geshi_code .sc2 {color: #339933;} .xml.geshi_code .sc3 {color: #009900;} .xml.geshi_code .re0 {color: #000066;} .xml.geshi_code .re1 {color: #000000; font-weight: bold;} .xml.geshi_code .re2 {color: #000000; font-weight: bold;} .xml.geshi_code span.xtra { display:block; }
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.server2.ru/BackendService" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.server2.ru/BackendService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.server2.ru/BackendService">
<s:element name="ProcessQuery">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="query" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ProcessQueryResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ProcessQueryResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="ProcessQuerySoapIn">
<wsdl:part name="parameters" element="tns:ProcessQuery" />
</wsdl:message>
<wsdl:message name="ProcessQuerySoapOut">
<wsdl:part name="parameters" element="tns:ProcessQueryResponse" />
</wsdl:message>
<wsdl:portType name="AviaProviderSoap">
<wsdl:operation name="ProcessQuery">
<wsdl:input message="tns:ProcessQuerySoapIn" />
<wsdl:output message="tns:ProcessQuerySoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AviaProviderSoap" type="tns:AviaProviderSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ProcessQuery">
<soap:operation soapAction="http://www.server2.ru/BackendService/ProcessQuery" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="AviaProviderSoap12" type="tns:AviaProviderSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ProcessQuery">
<soap12:operation soapAction="http://www.server2.ru/BackendService/ProcessQuery" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AviaProvider">
<wsdl:port name="AviaProviderSoap" binding="tns:AviaProviderSoap">
<soap:address location="http://www.server1.ru/BackendService/AviaProvider.asmx" />
</wsdl:port>
<wsdl:port name="AviaProviderSoap12" binding="tns:AviaProviderSoap12">
<soap12:address location="http://www.server1.ru/BackendService/AviaProvider.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Вот классы, сгенерированные с помощью wsdl2php:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
<?php
class ProcessQuery {
public $query; // string
}
class ProcessQueryResponse {
public $ProcessQueryResult; // string
}
/**
* AviaProvider class
*
*
*
* @author {author}
* @copyright {copyright}
* @package {package}
*/
class AviaProvider extends SoapClient {
private static $classmap = array(
'ProcessQuery' => 'ProcessQuery',
'ProcessQueryResponse' => 'ProcessQueryResponse',
);
public function AviaProvider($wsdl = "http://www.server1.ru/BackendService/AviaProvider.asmx?wsdl", $options = array()) {
foreach(self::$classmap as $key => $value) {
if(!isset($options['classmap'][$key])) {
$options['classmap'][$key] = $value;
}
}
parent::__construct($wsdl, $options);
}
/**
*
*
* @param ProcessQuery $parameters
* @return ProcessQueryResponse
*/
public function ProcessQuery(ProcessQuery $parameters) {
return $this->__soapCall('ProcessQuery', array($parameters), array(
'uri' => 'http://www.server2.ru/BackendService',
'soapaction' => ''
)
);
}
}
?>
UPD 2:
Пробовала вот так:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$client = new SoapClient($wsdl);
$answer = $client->ProcessQuery($xml);
Получаю ошибку о нехватке какого-то параметра s, который не может быть null.
UPD 3:
Пробую так:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$client = new SoapClient($wsdl);
$params = new stdClass();
$params->query = $xml;
$answer = $client->ProcessQuery($params);
Получаю ошибку уже на своей стороне: Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: string ' TimeTable 1 0 xd1...' is not a valid utf-8 string
Но мне нужно, во-первых, чтобы сервер получил данные как раз в windows-1251 кодировке!
Во-вторых, я не вижу тут XML, который передаю в переменной $xml - тут перечисляются только значения из тэгов XML...
Цитата из сопроводительного документа:
"Запросы к серверу оформляются в виде XML по изложенным ниже правилам... Пример XML:" - пример XML выше.
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$request = array(
'WEB' => array(
'XML1' => 'row1',
'XML2' => array(
'row2_1' => 1,
'row2_2' => 0,
'row2_3' => 'row2_3',
'row2_4' => 'row2_4',
'row2_5' => 0,
'row2_6' => 'row2_6'
)
)
);
Но у самого верхнего узла есть параметры, это выглядит так:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .xml.geshi_code {font-family:monospace;} .xml.geshi_code .imp {font-weight: bold; color: red;} .xml.geshi_code .es0 {color: #000099; font-weight: bold;} .xml.geshi_code .br0 {color: #66cc66;} .xml.geshi_code .sy0 {color: #66cc66;} .xml.geshi_code .st0 {color: #ff0000;} .xml.geshi_code .sc-1 {color: #808080; font-style: italic;} .xml.geshi_code .sc0 {color: #00bbdd;} .xml.geshi_code .sc1 {color: #ddbb00;} .xml.geshi_code .sc2 {color: #339933;} .xml.geshi_code .sc3 {color: #009900;} .xml.geshi_code .re0 {color: #000066;} .xml.geshi_code .re1 {color: #000000; font-weight: bold;} .xml.geshi_code .re2 {color: #000000; font-weight: bold;} .xml.geshi_code span.xtra { display:block; }
<?xml version="1.0" encoding="windows-1251"?>
<WEB a="1" c="1">
... тут остальной XML
</WEB>
Как правильно написать SOAP request, чтобы передались эти параметры a и c?
UPD 1: все, что есть - WSDL и пример запроса в виде готового XML.
Я уже попробовала вот это: http://www.urdalen.no/wsdl2php/index.php
Получила на выходе класс. Но как работать дальше с этим классом - непонятно, потому что тот пример, который по ссылке выше - уже недоступен.
Вот WSDL (реальные адреса заменены на server1 и server2):
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .xml.geshi_code {font-family:monospace;} .xml.geshi_code .imp {font-weight: bold; color: red;} .xml.geshi_code .es0 {color: #000099; font-weight: bold;} .xml.geshi_code .br0 {color: #66cc66;} .xml.geshi_code .sy0 {color: #66cc66;} .xml.geshi_code .st0 {color: #ff0000;} .xml.geshi_code .sc-1 {color: #808080; font-style: italic;} .xml.geshi_code .sc0 {color: #00bbdd;} .xml.geshi_code .sc1 {color: #ddbb00;} .xml.geshi_code .sc2 {color: #339933;} .xml.geshi_code .sc3 {color: #009900;} .xml.geshi_code .re0 {color: #000066;} .xml.geshi_code .re1 {color: #000000; font-weight: bold;} .xml.geshi_code .re2 {color: #000000; font-weight: bold;} .xml.geshi_code span.xtra { display:block; }
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.server2.ru/BackendService" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.server2.ru/BackendService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.server2.ru/BackendService">
<s:element name="ProcessQuery">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="query" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ProcessQueryResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ProcessQueryResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="ProcessQuerySoapIn">
<wsdl:part name="parameters" element="tns:ProcessQuery" />
</wsdl:message>
<wsdl:message name="ProcessQuerySoapOut">
<wsdl:part name="parameters" element="tns:ProcessQueryResponse" />
</wsdl:message>
<wsdl:portType name="AviaProviderSoap">
<wsdl:operation name="ProcessQuery">
<wsdl:input message="tns:ProcessQuerySoapIn" />
<wsdl:output message="tns:ProcessQuerySoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AviaProviderSoap" type="tns:AviaProviderSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ProcessQuery">
<soap:operation soapAction="http://www.server2.ru/BackendService/ProcessQuery" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="AviaProviderSoap12" type="tns:AviaProviderSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="ProcessQuery">
<soap12:operation soapAction="http://www.server2.ru/BackendService/ProcessQuery" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AviaProvider">
<wsdl:port name="AviaProviderSoap" binding="tns:AviaProviderSoap">
<soap:address location="http://www.server1.ru/BackendService/AviaProvider.asmx" />
</wsdl:port>
<wsdl:port name="AviaProviderSoap12" binding="tns:AviaProviderSoap12">
<soap12:address location="http://www.server1.ru/BackendService/AviaProvider.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Вот классы, сгенерированные с помощью wsdl2php:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
<?php
class ProcessQuery {
public $query; // string
}
class ProcessQueryResponse {
public $ProcessQueryResult; // string
}
/**
* AviaProvider class
*
*
*
* @author {author}
* @copyright {copyright}
* @package {package}
*/
class AviaProvider extends SoapClient {
private static $classmap = array(
'ProcessQuery' => 'ProcessQuery',
'ProcessQueryResponse' => 'ProcessQueryResponse',
);
public function AviaProvider($wsdl = "http://www.server1.ru/BackendService/AviaProvider.asmx?wsdl", $options = array()) {
foreach(self::$classmap as $key => $value) {
if(!isset($options['classmap'][$key])) {
$options['classmap'][$key] = $value;
}
}
parent::__construct($wsdl, $options);
}
/**
*
*
* @param ProcessQuery $parameters
* @return ProcessQueryResponse
*/
public function ProcessQuery(ProcessQuery $parameters) {
return $this->__soapCall('ProcessQuery', array($parameters), array(
'uri' => 'http://www.server2.ru/BackendService',
'soapaction' => ''
)
);
}
}
?>
UPD 2:
Пробовала вот так:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$client = new SoapClient($wsdl);
$answer = $client->ProcessQuery($xml);
Получаю ошибку о нехватке какого-то параметра s, который не может быть null.
UPD 3:
Пробую так:
/** * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann * (http://qbnz.com/highlighter/ and http://geshi.org/) */ .php.geshi_code {font-family:monospace;} .php.geshi_code .imp {font-weight: bold; color: red;} .php.geshi_code .kw1 {color: #b1b100;} .php.geshi_code .kw2 {color: #000000; font-weight: bold;} .php.geshi_code .kw3 {color: #990000;} .php.geshi_code .co1 {color: #666666; font-style: italic;} .php.geshi_code .co2 {color: #666666; font-style: italic;} .php.geshi_code .co3 {color: #0000cc; font-style: italic;} .php.geshi_code .co4 {color: #009933; font-style: italic;} .php.geshi_code .coMULTI {color: #666666; font-style: italic;} .php.geshi_code .es0 {color: #000099; font-weight: bold;} .php.geshi_code .es1 {color: #000099; font-weight: bold;} .php.geshi_code .es2 {color: #660099; font-weight: bold;} .php.geshi_code .es3 {color: #660099; font-weight: bold;} .php.geshi_code .es4 {color: #006699; font-weight: bold;} .php.geshi_code .es5 {color: #006699; font-weight: bold; font-style: italic;} .php.geshi_code .es6 {color: #009933; font-weight: bold;} .php.geshi_code .es_h {color: #000099; font-weight: bold;} .php.geshi_code .br0 {color: #009900;} .php.geshi_code .sy0 {color: #339933;} .php.geshi_code .sy1 {color: #000000; font-weight: bold;} .php.geshi_code .st0 {color: #0000ff;} .php.geshi_code .st_h {color: #0000ff;} .php.geshi_code .nu0 {color: #cc66cc;} .php.geshi_code .nu8 {color: #208080;} .php.geshi_code .nu12 {color: #208080;} .php.geshi_code .nu19 {color:#800080;} .php.geshi_code .me1 {color: #004000;} .php.geshi_code .me2 {color: #004000;} .php.geshi_code .re0 {color: #000088;} .php.geshi_code span.xtra { display:block; }
$client = new SoapClient($wsdl);
$params = new stdClass();
$params->query = $xml;
$answer = $client->ProcessQuery($params);
Получаю ошибку уже на своей стороне: Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: string ' TimeTable 1 0 xd1...' is not a valid utf-8 string
Но мне нужно, во-первых, чтобы сервер получил данные как раз в windows-1251 кодировке!
Во-вторых, я не вижу тут XML, который передаю в переменной $xml - тут перечисляются только значения из тэгов XML...
Цитата из сопроводительного документа:
"Запросы к серверу оформляются в виде XML по изложенным ниже правилам... Пример XML:" - пример XML выше.
1 ответов
А у вас имеется WSDL? Скорее всего я не въехал в тему но вот какие есть мысли:
$client = new SoapClient($url . '?wsdl');
$params = new stdClass();
$params->id = $id;
$params->param = $param;
$res = $client->WebServiceFunction($params);
Примеры еще есть http://www.phpclub.ru/detail/article/soap
UPD: Согласен с dm.CaT. Оно должно работать и без оберток примерно так:
$client = new SoapClient($url); // $url - адрес wsdl документа
$params = new stdClass();
$params->query = $query; // $query - скорее всего сюда и надо XML
$res = $client->ProcessQuery($params);
UPD2: Так вы не пробовали работать со сгенерироваными классами?
$pq = new ProcessQuery();
$pq->query = "<xml></xml>";
$client = new AviaProvider($wsdl);
$client->ProcessQuery($pq);
SOAP - это протокол передачи сообщений. Он стандартизирован. Соответственно, правильно писать запрос, означает, писать его в соответствии со стандартом: http://www.w3.org/TR/soap12-part1/.