jaxb(jax-ws) soap WSDL - 方法中缺少参数

jaxb(jax-ws) soap WSDL - absent parameters in methods

我制作了一个 SOAP 应用程序,它有一个 @WebService 接口和实现,可以通过发布者 class 或从 Tomcat 启动。问题是:生成的 WSDL 不包含 <complexType> 的结构,因此内部没有元素。这就是我想要的:

<xs:complexType name="customer">
  <xs:sequence>
  <xs:element name="age" type="xs:int"/>
  <xs:element name="name" type="xs:string" minOccurs="0"/>
</xs:sequence>

(好吧,这不是方法,但是方法在 OK wsdl 中包含类似的东西) 因此,我制作了一个 helloworld 应用程序来尝试生成良好的 WSDL;创建了一个实体 "Customer",并使用 SchemaOutputResolver,而不是 @WebInterface-implementation-publisher 方法来获取上面的 WSDL。 但是,当我为 helloworld 网络服务(使用单一方法)制作时:

    @WebService
public interface CustomerServInterface {
    @WebMethod
    String gimmeCustomer(@WebParam(name = "CustomerY") Customer customer);
}

,它的实现:

    @WebService(endpointInterface = "myJaxb.CustomerServInterface")
public class CustomerServImpl implements CustomerServInterface {
    @Override
    public String gimmeCustomer(@WebParam(name = "CustomerQQ") Customer customer) {
        if (customer != null) return "Received!";
        else return "received null";
    }
}

,出版商:

public class CustomerServPublisher {
    public static void main(String[] args) {
        System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");

        Endpoint.publish("http://localhost:8080/customer", new CustomerServImpl());
    }
}

,并且已经有客户的 class @XmlRootElement 和它的每个字段 @XmlElement(这显然以前有效),我从发布者那里获得的 WSDL 再次没有参数:

<types>
<xsd:schema>
<xsd:import namespace="http://myJaxb/" schemaLocation="http://localhost:8080/customer?xsd=1"/>
</xsd:schema>
</types>
<message name="gimmeCustomer">
<part name="parameters" element="tns:gimmeCustomer"/>
</message>
<message name="gimmeCustomerResponse">
<part name="parameters" element="tns:gimmeCustomerResponse"/>
</message>
<portType name="CustomerServInterface">
<operation name="gimmeCustomer">
<input wsam:Action="http://myJaxb/CustomerServInterface/gimmeCustomerRequest" message="tns:gimmeCustomer"/>
<output wsam:Action="http://myJaxb/CustomerServInterface/gimmeCustomerResponse" message="tns:gimmeCustomerResponse"/>
</operation>
</portType>
<binding name="CustomerServImplPortBinding" type="tns:CustomerServInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="gimmeCustomer">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>

(为方便起见,将其截断了一点)

不仅缺少方法的 gimmeCustomer 参数(客户或 CustomerY 或 CustomerQQ),而且 class 根本没有客户! 我绝对不明白。 Google 也没有给出太多答案(尽管我不是唯一有这个问题的人)。我好像不理解一些很明显的东西。

提前感谢您提供有用的信息。

所以,我没有直接弄明白。相反,我将样式更改为 RPC:

@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface CustomerServInterface {

这使得方法参数显示为 arg0、arg1 等。然后

String authorize(@WebParam(name = "login") String login) {

@WebParam 在每个参数(在接口 class 中)解决名称问题之前。

但是,根据 jax-ws RPC 与来自 google 的文档描述判断,这是一个不需要的更改。嗯

现在的问题是实体 class 客户本身没有映射到我的 WSDL,尽管

<message name="gimmeCustomer">
<part name="CustomerY" type="tns:customer"/>
</message>

tns 这里的意思是(大概)'customer' 应该出现在同一个 wsdl 中。但那是另一个话题了。