Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从CXF公开时如何在WSDL中指定数据类型_Java_Xml_Web Services_Soap_Wsdl - Fatal编程技术网

Java 从CXF公开时如何在WSDL中指定数据类型

Java 从CXF公开时如何在WSDL中指定数据类型,java,xml,web-services,soap,wsdl,Java,Xml,Web Services,Soap,Wsdl,我创建了一个简单的webservice,它接受一个customer对象,该对象有两个参数integer和string,如下所示 @WebService(endpointInterface="com.kaushik.serverside.intf.HelloWorld") public class HelloWorldImpl implements HelloWorld { @Resource WebServiceContext wsctx; public String g

我创建了一个简单的webservice,它接受一个customer对象,该对象有两个参数integer和string,如下所示

@WebService(endpointInterface="com.kaushik.serverside.intf.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
    @Resource
    WebServiceContext wsctx;
    public String getHelloWorldAsString1(Customer customer) {
}
@XmlRootElement
public class Customer {
    public String firstName;
    public int age;
}
在CXF-servelet.xml中公开了它

<bean id="hello" class="com.kaushik.serverside.impl.HelloWorldImpl"></bean>
    <jaxws:endpoint id="sayHelloEndpoint"
        implementor="#hello" address="/services/sayHelloService" />

生成的WSDL是

<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://impl.serverside.kaushik.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/wsdl/soap/http" xmlns:ns1="http://intf.serverside.kaushik.com/" targetNamespace="http://impl.serverside.kaushik.com/" name="HelloWorldImplService">
<wsdl:import namespace="http://intf.serverside.kaushik.com/" location="http://localhost:8080/webserviceWithCXFWebApp/servicewala/services/sayHelloService?wsdl=HelloWorld.wsdl"> </wsdl:import>
<wsdl:binding name="HelloWorldImplServiceSoapBinding" type="ns1:HelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="getHelloWorldAsString1">
<soap:operation style="document" soapAction=""/>
<wsdl:input name="getHelloWorldAsString1">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getHelloWorldAsString1Response">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldImplService">
<wsdl:port name="HelloWorldImplPort" binding="tns:HelloWorldImplServiceSoapBinding">
<soap:address location="http://localhost:8080/webserviceWithCXFWebApp/servicewala/services/sayHelloService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

-
从SoapUI工具生成请求时

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:intf="http://intf.serverside.kaushik.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <intf:getHelloWorldAsString1>
         <!--Optional:-->
         <arg0>
            <!--Optional:-->
            <firstName>?</firstName>
            <age>?</age>
         </arg0>
      </intf:getHelloWorldAsString1>
   </soapenv:Body>
</soapenv:Envelope>

但SoapUI工具并没有将匹配值限制为所需的数据类型。正如在接受的答案中指出的,WSDL指向另一个包含数据类型的文件,即。wsdl:导入位置=”http://localhost:8080/webserviceWithCXFWebApp/servicewala/services/sayHelloService?wsdl=HelloWorld.wsdl


SoapUI工具自动处理下载和使用此文件。

您发布的WSDL不包含任何类型信息。它只包含soap操作和服务的绑定。请转到此URL以获取类型信息:


你能得到你发布的WSDL中包含的WSDL吗?当我点击这个URL时,我可以看到XML,它有类型定义。但是我不能在SoaUI中导入它。如果我下载它,然后导入到导入文件中。仍然不成功。它说“找不到要导入的内容…”。谢谢。我得到了它。请检查我问题中的编辑以获得答案。