有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java WSDL为元素类型提供不同的名称空间

我正在创建web服务,因此必须修改。WSDL来添加它们。当我这样做时,我在这行上有一个错误:

<s:element minOccurs="0" maxOccurs="1" name="MonitoringResult" type="tms:State" />

undefined simple or complex type 'tms:State' (org.apache.cxf:cxf-codegen-plugin:3.0.4:wsdl2java:generate-sources:generate-sources)

下面是我的WSDL声明:

<wsdl:definitions 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
    xmlns:tms="http://***.com/***/evpt/util" 
    xmlns:tns="http://***.com/***/evpt/services/v1_0_0" 
    xmlns:s="http://www.w3.org/2001/XMLSchema" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
    targetNamespace="http://***.com/***/evpt/services/v1_0_0" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

这段代码运行良好,readObject()方法返回了一个在tns:ObjectSet中定义的ObjectSet(ObjectSet.java类位于http://.com//evpt/services/v1_0_0/ObjectSet.java中)

  <s:element name="ReadObjects">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="keySet" type="tns:ObjectKeySet" />
      </s:sequence>
    </s:complexType>
  </s:element>
  <s:element name="ReadObjectsResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="ReadObjectsResult" type="tns:ObjectSet" />
      </s:sequence>
    </s:complexType>
  </s:element>

但是我创建了另一个web方法,它返回一个类在http://中定义的状态。com//evpt/util/State。JAVA当我尝试这个:

<s:element name="Monitoring">
    <s:complexType/>
</s:element>
<s:element name="MonitoringResponse">
    <s:complexType>
        <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="MonitoringResult" type="tms:State" />
        </s:sequence>
    </s:complexType>
</s:element>

它返回一个状态错误。所以我在wsdl定义中定义了一个名为“tms”的名称空间,但它仍然不起作用

你们能帮帮我吗?谢谢

编辑:

package com.***.***.evpt.util;

public enum State {
    RUNNING,
    STOPPED;
}

共 (0) 个答案