WSDL 创建解析错误



我正在尝试公开SOAP Web服务。为此,我正在使用阿帕奇骆驼。所以我必须使用 apache CXF 来公开 SOAP Web 服务。但是我得到了以下错误。

org.xml.sax.SAXParseException; 行号:2; 列数:223;这 属性的值 "prefix="xmlns",localpart="tns",rawname="xmlns:tns" 无效。 带前缀的命名空间绑定不能为空。

这是我编码的以下内容。

@WebService(endpointInterface="com.ericsson.fdp.SOAP.FulfillmentService", targetNamespace = "http://apache.org/hello_world_soap_http",portName="FulfillmentServicePort",serviceName="FulfillmentService")
public class FulfillmentServiceImpl implements FulfillmentService{

@Produce(uri = "servlet:///fulfillmentService?servletName=FulfillmentService&matchOnUriPrefix=false")
private ProducerTemplate template;
@Override
public FulfillmentResponse buyProduct(String input, String userName, String password, String msisdn, String iname) {
Map<String,Object> queryMap = new HashMap<>();
queryMap.put("input", input);
queryMap.put("password", password);
queryMap.put("msisdn", msisdn);
queryMap.put("iname", iname);

String response = (String) template.requestBodyAndHeaders(null, queryMap);
FulfillmentResponse responseObject=null;
try {
responseObject = XmlUtil.unmarshall(response, FulfillmentResponse.class);
} catch (JAXBException e) {
e.printStackTrace();
}
return responseObject;
}

}

这是上述实现的接口

@WebService(name="fulfillmentService", targetNamespace = "http://apache.org/hello_world_soap_http",portName="FulfillmentServicePort",serviceName="FulfillmentService")
public interface FulfillmentService {
public FulfillmentResponse buyProduct(String input,String userName, String password,String msisdn,String iname);
}

我试着办理入住手续。这是为上述代码创建的 WSDL。

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="fulfillmentService" targetNamespace="" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://apache.org/hello_world_soap_http" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:import namespace="http://apache.org/hello_world_soap_http" location="fulfillmentService.wsdl">
</wsdl:import>
<wsdl:binding name="fulfillmentServiceSoapBinding" type="ns1:fulfillmentService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="buyProduct">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="buyProduct">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="buyProductResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="fulfillmentService">
<wsdl:port name="fulfillmentServicePort" binding="fulfillmentServiceSoapBinding">
<soap:address location="http://127.0.0.1:8980/cisBusiness/services/fulFillment"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

如何修复此错误?

尝试将相同的命名空间添加到以下内容。

xmlns:tns="http://www.example.org" targetNamespace="http://www.example.org"

当然,您可以将"http://www.example.org"更改为您喜欢的东西......

最新更新