繁体   English   中英

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

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

我制作了一个SOAP应用程序,它具有@WebService接口和实现,可以通过发布者类或从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>

(嗯,这不是方法,但是方法在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());
    }
}

,并且已经有Customer的类@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参数(customer或CustomerY或CustomerQQ),而且根本没有对Customer进行分类! 而且我绝对不明白。 Google也没有给出太多答案(尽管我并不孤单)。 我跌跌撞撞,好像不了解一些显而易见的事情。

在此先感谢您提供有用的信息。

因此,我没有直接弄清楚这一点。 相反,我将样式更改为RPC:

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

并使方法参数显示为arg0,arg1等。然后

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

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

但是,从jax-ws RPC与Google的文档描述来看,这是一个不希望的更改。

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

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

这里的tns意味着(大概)“客户”应该出现在同一wsdl中。 但这是另一个话题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM