веб-сервисы — WSDL Api в переполнении стека

Я хочу разрабатывать WSDL-сервисы на PHP.

Я создал один файл PHP index.php, Я позвонил hello.wsdl файл с помощью SOAP.

Код здесь:

 <?php
$client = new soapclient('`http://localhost/test/hello.wsdl`');
$response=$client->addSubscriber('EMtest', 44983, 'name@example.com', 'Name');
echo $response;
?>

мой hello.wsdl код файла здесь:

    <?xml version="1.0"?>
<definitions name="MyDefinition"targetNamespace="urn:myTargetNamespace"xmlns:tns="urn:myTns"xmlns:xsd="`http://www.w3.org/2001/XMLSchema`"xmlns:soap="`http://schemas.xmlsoap.org/wsdl/soap/`"xmlns="`http://schemas.xmlsoap.org/wsdl/`">
<message name="addSubscriberRequest">
<part name="api_key" type="xsd:string"/>
<part name="group_id" type="xsd:int"/>
<part name="email" type="xsd:string"/>
<part name="name" type="xsd:string"/>
</message>
<message name="addSubscriberResponse">
<part name="error" type="tns:ErrorTypeEnum"/>
</message>

<operation name="addSubscriber

">
<input message="tns:addSubscriberRequest"/>
<output message="tns:addSubscriberResponse"/>

Но я не могу получить ответ на запрос мыла …
У меня есть некоторые ошибки, например:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '`http://localhost/test/hello.php?wsdl`' : Start tag expected, '<' not found in /var/www/test/index.php:39 Stack trace: #0 /var/www/test/index.php(39): SoapClient->SoapClient('`http://localhost...`') #1 {main} thrown in /var/www/test/index.php on line 39

Пожалуйста, объясните мне, как вызывать SOAP и как создавать WSDL-сервис на PHP,
Также, пожалуйста, исправьте мой код …

0

Решение

Ваш WSDL неполный, есть еще много работы. Я бы посоветовал вам сначала начать моделировать операции запроса и ответа с использованием XSD, а затем импортировать этот XSD в WSDL и использовать его оттуда.

Вам понадобится хороший WSDL-редактор, такой как Altova XML Spy или Liquid XML Studio. Ниже приведен пример того, как должен выглядеть ваш минимальный WSDL. Я хотел бы предложить вам сравнить этот скелет с вашим и понять различия.

Вещи, которые вам не хватает:

  • Информация схемы (XSD) вокруг запроса, ответа и объекта, передаваемого этим операциям.
  • Определение порта
  • Определение сервиса
  • Наручники.

Если вы серьезно относитесь к использованию веб-сервисов, понимание этих основных концепций имеет решающее значение. Я предлагаю вам сначала понять эти концепции, а затем вернуться, когда у вас возникнут конкретные проблемы, которые мы можем решить.

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="Hello"targetNamespace="http://mycompanyurl.com/HelloService_v1"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"xmlns:tns="http://mycompanyurl.com/HelloService_v1"xmlns:xs="http://www.w3.org/2001/XMLSchema"xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema elementFormDefault="qualified"targetNamespace="http://example.com/">
<xs:element name="InputType">
<xs:complexType>
<xs:sequence>
<xs:element name="input"type="string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="OutputType">
<xs:complexType>
<xs:sequence>
<xs:element name="output"type="string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="addSubscriberRequest">
<wsdl:part name="InputMessagePart"element="tns:InputType" />
</wsdl:message>
<wsdl:message name="addSubscriberResponse">
<wsdl:part name="OutputMessagePart"element="tns:OutputType" />
</wsdl:message>
<wsdl:portType name="HelloServicePortType">
<wsdl:operation name="addSubscriber">
<wsdl:input message="tns:addSubscriberRequest" />
<wsdl:output message="tns:addSubscriberResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloHTTPBinding"type="tns:HelloServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"style="document" />
<wsdl:operation name="addSubscriber">
<wsdl:input />
<wsdl:output />
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloService">
<wsdl:port name="HelloPort"
binding="tns:HelloHTTPBinding">
<soap:address location="http://mycompanyurl.helloservice.com" />
</wsdl:port>
</wsdl:service>

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector