Apache Axis:不包含元素

Mic*_*zak 6 java apache axis soap web-services

我从供应商那里收到了以下WSDL.它背后的示例服务在Microsoft .NET上运行.我需要基于此WSDL在Java中创建Web服务.

<?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>
Run Code Online (Sandbox Code Playgroud)

我修改了我收到的WSDL以包含以下行,以便Eclipse将WSDL识别为有效:

<s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd" />  <!--  added for Eclipse-->
Run Code Online (Sandbox Code Playgroud)

我已将此WSDL文件包含在新的Dynamic Web Project中.我使用New Web Service向导基于WSDL创建一个新的自上而下的Web服务.

当我将项目部署到Tomcat并调用Web服务时,Apache Axis会报告以下内容:

AXIS错误

对不起,似乎出了点问题...这里有详细信息:

错误 - makeTypeElement()被告知创建一个类型"{ http://www.somecompany.com/ } >> getInventoryStatusResponse> getInventoryStatusResult",没有包含元素

AxisFault faultCode:{ http://schemas.xmlsoap.org/soap/envelope/ } Server.generalException faultSubcode:faultString:makeTypeElement()被告知要创建一个类型"{ http://www.somecompany.com/ } >> getInventoryStatusResponse> getInventoryStatusResult",没有包含元素faultActor:faultNode:faultDetail:{ http://xml.apache.org/axis/ } hostname:HOME-DELL

供应商提供的演示Web服务返回以下内容:

<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>
Run Code Online (Sandbox Code Playgroud)

我想我需要在WSDL中引用NewDataSet的模式,但我不知道该怎么做.

act*_*ctc 0

你知道soapUI吗?您可以导入 WSDL 并对演示服务发出一些请求。只是为了检查您的基础设施是否正常运行。

如果一切似乎都正常,请尝试以下操作:让 Java 通过“wsimport”命令从 WSDL 生成类,如下所示:

%JAVA_HOME%/bin/wsimport -d [RELATIVE_PATH_FOR_GENERATED_CLASSES] -编码 UTF-8 -keep -verbose [RELATIVE_PATH_OF_YOUR_WSDL]

在您的代码中尝试使用这些生成的类并再次部署。

您可以从这里获取 wsimport 的完整文档

希望能以任何方式提供帮助。