Я очень новичок в веб-сервисах, и я хотел бы знать, как можно было бы сэкономить типы define в разделе wsdl: type в своей собственной схеме с идеей, что можно повторно использовать схему в нескольких WSDL. Я пытаюсь использовать оператор импорта, как показано ниже, но это не очень успешно.Как отделить встроенную схему внутри WSDL?
<wsdl:types>
<xsd:schema targetNamespace="http://ttdev.com/ss">
<xsd:import namespace="http://ttdev.com/ss"schemaLocation="http://ttdev.com/ss/SimpleService.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ttdev.com/ss" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SimpleService" targetNamespace="http://ttdev.com/ss" xmlns:xi="http://www.w3.org/2001/XInclude">
<wsdl:types>
<xsd:schema targetNamespace="http://ttdev.com/ss">
<xsd:element name="concatRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="param1" type="xsd:string"/>
<xsd:element name="param2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="concatResponse">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="100">
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="concatRequest">
<wsdl:part name="parameters" element="tns:concatRequest"/>
</wsdl:message>
<wsdl:message name="concatResponse">
<wsdl:part name="parameters" element="tns:concatResponse"/>
</wsdl:message>
<wsdl:portType name="SimpleService">
<wsdl:operation name="concat">
<wsdl:input message="tns:concatRequest"/>
<wsdl:output message="tns:concatResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleServiceSOAP" type="tns:SimpleService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="concat">
<soap:operation soapAction="http://ttdev.com/ss/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleService">
<wsdl:port name="p1" binding="tns:SimpleServiceSOAP">
<soap:address location="http://localhost:8080/ss/p1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Резюмируя:
- Я изолировал схему в свой собственный файл SinpleService.xsd (в соответствии с кодом образца ниже)
- Я добавил оператор импорта в WSDL, как указано выше ,
- Однако похоже, что типы не могут быть разрешены, когда я ссылаюсь на них через импорт.
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://ttdev.com/ss" targetNamespace="http://ttdev.com/ss">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://www.w3.org/2001/XMLSchema"/>
<xsd:element name="concatRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="param1" type="xsd:string"/>
<xsd:element name="param2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="concatResponse">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="100">
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
'import' правильный подход, придерживаться его. Скажите, почему он не работает. – skaffman
WSDL не выполняет проверку, это ошибка, которую я возвращаю: C: \ Users \ User \ workspace \ Axis2SimpleService \ src \ main \ resources \ SimpleService.wsdl недопустим. Символ '' является грамматически неожиданным. Причина: ожидается одно из следующего (см. Ниже) '/>' '>' S Подробное описание XML-продукции: элемент «Production» не удовлетворен – user465374
xsd: import: отсутствует пробел после атрибута пространства имен? – Osw