Tôi đã nhận được WSDL sau đây từ một nhà cung cấp. Dịch vụ mẫu đằng sau nó chạy trên Microsoft .NET. Tôi cần tạo một dịch vụ web bằng Java dựa trên WSDL này.Apache Axis: không chứa phần tử
<?xml version="1.0" encoding="utf-8"?>
<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.somecompany.com/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://www.somecompany.com/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.somecompany.com/">
<s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd" />
<s:element name="getInventoryStatus">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DealerCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SupplierCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PartNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="Quantity" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="DeliveryLocation" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getInventoryStatusResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="getInventoryStatusResult">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="getInventoryStatusSoapIn">
<wsdl:part name="parameters" element="tns:getInventoryStatus" />
</wsdl:message>
<wsdl:message name="getInventoryStatusSoapOut">
<wsdl:part name="parameters" element="tns:getInventoryStatusResponse" />
</wsdl:message>
<wsdl:portType name="InventoryInquirySoap">
<wsdl:operation name="getInventoryStatus">
<wsdl:input message="tns:getInventoryStatusSoapIn" />
<wsdl:output message="tns:getInventoryStatusSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="InventoryInquirySoap" type="tns:InventoryInquirySoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getInventoryStatus">
<soap:operation soapAction="http://www.somecompany.com/getInventoryStatus" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="InventoryInquiry">
<wsdl:port name="InventoryInquirySoap" binding="tns:InventoryInquirySoap">
<soap:address location="http://www.somecompany.com/InventoryInquiry.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Tôi đổi WSDL tôi nhận được để bao gồm các dòng sau để Eclipse sẽ nhận ra WSDL là hợp lệ:
<s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd" /> <!-- added for Eclipse-->
Tôi đã bao gồm tập tin WSDL này trong một mới Dự án Web động. Tôi đã sử dụng trình thủ thuật Dịch vụ Web Mới để tạo một dịch vụ web trên cùng mới dựa trên WSDL.
Khi tôi triển khai các dự án để Tomcat và gọi dịch vụ web, Apache Axis báo cáo lại như sau: lỗi
AXIS
Xin lỗi, một cái gì đó dường như đã đi sai ... đây là những chi tiết:
lỗi - makeTypeElement() được cho biết để tạo ra một loại "{} http://www.somecompany.com/ >> getInventoryStatusResponse> getInventoryStatusResult", với không có yếu tố chứa
AxisFault faultCode: {} http://schemas.xmlsoap.org/soap/envelope/ Server.generalException faultSubcode: faultString: makeTypeElement() được cho biết để tạo ra một loại "{} http://www.somecompany.com/ >> getInventoryStatusResponse> getInventoryStatusResult", với không có yếu tố chứa faultActor: faultNode: faultDetail : {} http://xml.apache.org/axis/ hostname: CHỦ-DELL
các dịch vụ web giới thiệu được cung cấp bởi các nhà cung cấp trả về như sau:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetInventoryStatusResponse xmlns="http://ctire.aktion.com/">
<GetInventoryStatusResult>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="InventoryStatus">
<xs:complexType>
<xs:sequence>
<xs:element name="InStock" type="xs:int" minOccurs="0"/>
<xs:element name="EstDeliveryDate" type="xs:string" minOccurs="0"/>
<xs:element name="EstDeliveryTime" type="xs:string" minOccurs="0"/>
<xs:element name="DeliveryLocation" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<InventoryStatus diffgr:id="InventoryStatus1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
<InStock>36</InStock>
<EstDeliveryDate>09/27/2016</EstDeliveryDate>
<EstDeliveryTime>12:00 PM</EstDeliveryTime>
<DeliveryLocation>883620750</DeliveryLocation>
</InventoryStatus>
</NewDataSet>
</diffgr:diffgram>
</GetInventoryStatusResult>
</GetInventoryStatusResponse>
</soap:Body>
</soap:Envelope>
Tôi nghĩ rằng tôi cần phải tham khảo một lược đồ cho NewDataSet trong WSDL, nhưng tôi không chắc chắn làm thế nào để làm điều đó.
sự khác biệt giữa wsimport là gì và sử dụng Axis, bao gồm ed với Eclipse? –
Vâng, tôi biết soapUI. Như đã lưu ý trong câu hỏi, vấn đề là tôi không thể truy cập dịch vụ mà Axis xây dựng, do một vấn đề với việc chuyển đổi Axis của các lớp WSDL thành các lớp Java. –
Bạn đã thử tạo các tạo phẩm qua wsimport chưa? Công cụ này đã phục vụ tôi nhiều hơn một lần. Kết quả của các công cụ khác - Tôi không thể nhớ mình đã thử nhưng tôi nghĩ AXIS là một trong số chúng - không hoạt động. – actc