Создание клиента веб-службы в режиме соответствия WS-I
Я пытаюсь создать клиент веб-службы с использованием Visual Studio 2010. Клиент работает очень хорошо, если я использую файл wsdl в версии SOAP V2.
Когда я устанавливаю свойство WS-I Compliance
в Yes
в Magento и перекомпилируйте клиент веб-службы в VS2010, это не работает!!! Некоторые методы исчезают из результирующего файла WSDL.
Я обнаружил ту же проблему, если сгенерировал клиент веб-службы Java с помощью инструмента. wsimport
,
Есть идеи о том, что происходит?
3 ответа
Я столкнулся с той же проблемой, и вместо того, чтобы закомментировать каталог ProductAttributeRemove, я фактически изучил то, чего не хватало, и добавил дополнительные разделы в свой файл wsi.xml. Спасибо Juanma R. за указание мне в направлении файла, который нужно исправить.
Я ссылался на записи для catalogProductAttributeCreate в качестве ориентира для того, что другие разделы, возможно, должны существовать, чтобы исправить это. Я ничего не знаю о WSDL, просто попытался найти то, что может отсутствовать.
После изменения файла я обновил все кэши в Magento и подтвердил, что новые записи отображаются в файле WSDL по адресу /index.php/api/v2_soap?wsdl=1. Затем я удалил веб-ссылку, которая была добавлена в VS 2010, и снова прошел процедуру добавления веб-ссылки. На этот раз после добавления я не получил ошибок.
Версией Magento, которую я исправлял, является Magento Enterprise 1.12.0.2, но я ожидаю, что она применима к другим версиям, которые показывают ту же ошибку с catalogProductAttributeRemove.
Вот быстрый анализ того, что я изменил в файле wsi.xml:
*** Z:\mage-1-12-0-2.dev\htdocs\app\code\core\Mage\Catalog\etc\wsi - Copy.xml backup Tue Jul 3 12:08:31 2012 UTC
--- Z:\mage-1-12-0-2.dev\htdocs\app\code\core\Mage\Catalog\etc\wsi.xml Fri Nov 9 18:40:58 2012 UTC
***************
*** 1509,1520 ****
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="catalogProductCurrentStoreRequest">
<wsdl:part name="parameters" element="typens:catalogProductCurrentStoreRequestParam" />
</wsdl:message>
<wsdl:message name="catalogProductCurrentStoreResponse">
--- 1509,1540 ----
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
+
+
+ <!-- Added by Matt Johnson 2012-11-09 to fix VS 2010 support of SOAP reference -->
+ <xsd:element name="catalogProductAttributeRemoveRequestParam">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
+ <xsd:element minOccurs="1" maxOccurs="1" name="attribute" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="catalogProductAttributeRemoveResponseParam">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="1" maxOccurs="1" name="result" type="xsd:boolean" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+
</xsd:schema>
</wsdl:types>
<wsdl:message name="catalogProductCurrentStoreRequest">
<wsdl:part name="parameters" element="typens:catalogProductCurrentStoreRequestParam" />
</wsdl:message>
<wsdl:message name="catalogProductCurrentStoreResponse">
***************
*** 1883,1894 ****
<wsdl:message name="catalogProductAttributeCreateRequest">
<wsdl:part name="parameters" element="typens:catalogProductAttributeCreateRequestParam" />
</wsdl:message>
<wsdl:message name="catalogProductAttributeCreateResponse">
<wsdl:part name="parameters" element="typens:catalogProductAttributeCreateResponseParam" />
</wsdl:message>
<wsdl:portType name="{{var wsdl.handler}}PortType">
<wsdl:operation name="catalogCategoryCurrentStore">
<wsdl:documentation>Set_Get current store view</wsdl:documentation>
<wsdl:input message="typens:catalogCategoryCurrentStoreRequest" />
<wsdl:output message="typens:catalogCategoryCurrentStoreResponse" />
</wsdl:operation>
--- 1903,1923 ----
<wsdl:message name="catalogProductAttributeCreateRequest">
<wsdl:part name="parameters" element="typens:catalogProductAttributeCreateRequestParam" />
</wsdl:message>
<wsdl:message name="catalogProductAttributeCreateResponse">
<wsdl:part name="parameters" element="typens:catalogProductAttributeCreateResponseParam" />
</wsdl:message>
+
+ <!-- Added by Matt Johnson 2012-11-09 to fix VS 2010 support of SOAP reference -->
+ <wsdl:message name="catalogProductAttributeRemoveRequest">
+ <wsdl:part name="parameters" element="typens:catalogProductAttributeRemoveRequestParam" />
+ </wsdl:message>
+ <wsdl:message name="catalogProductAttributeRemoveResponse">
+ <wsdl:part name="parameters" element="typens:catalogProductAttributeRemoveResponseParam" />
+ </wsdl:message>
+
<wsdl:portType name="{{var wsdl.handler}}PortType">
<wsdl:operation name="catalogCategoryCurrentStore">
<wsdl:documentation>Set_Get current store view</wsdl:documentation>
<wsdl:input message="typens:catalogCategoryCurrentStoreRequest" />
<wsdl:output message="typens:catalogCategoryCurrentStoreResponse" />
</wsdl:operation>
***************
*** 2760,2771 ****
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="{{var wsdl.name}}Service">
<wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
<soap:address location="{{var wsdl.url}}" />
</wsdl:port>
</wsdl:service>
--- 2789,2814 ----
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
+
+
+ <!-- Added by Matt Johnson 2012-11-09 to fix VS 2010 support of SOAP reference -->
+ <wsdl:operation name="catalogProductAttributeRemove">
+ <soap:operation soapAction="" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+
</wsdl:binding>
<wsdl:service name="{{var wsdl.name}}Service">
<wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
<soap:address location="{{var wsdl.url}}" />
</wsdl:port>
</wsdl:service>
В исходном коде Magento Core есть ошибка, связанная с операцией "catalogProductAttributeRemove" (модуль core/Mage/Catalog).
Чтобы решить эту проблему, я прокомментировал следующую операцию в файле wsi.xml модуля Catalog
<!--wsdl:operation name="catalogProductAttributeRemove">
<wsdl:documentation>Delete attribute</wsdl:documentation>
<wsdl:input message="typens:catalogProductAttributeRemoveRequest" />
<wsdl:output message="typens:catalogProductAttributeRemoveResponse" />
</wsdl:operation-->
После этого автоматическое построение клиента Web-сервиса с использованием VS2010 работает отлично!
Я включил diff в wsi.xml с версии 1.7.2 и загрузил его здесь.
Так что, если вы не можете правильно прочитать diff, вы можете использовать этот файл напрямую.