java - WSDL 创建解析错误
问题描述
我正在尝试公开 SOAP Web 服务。为此,我使用的是 apache camel。所以我必须使用 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 ”更改为您喜欢的内容...
推荐阅读
- r - 如何在R中将两帧合并为一帧
- python-2.7 - 如何获取放置在 tkinter python 网格中的小部件的行号和列号?
- c++ - SDL_DestroyWindow 不释放内存
- ios - 如何在 Swift 5.1 (Xcode 11 Playground) 中实现可选的泛型和非泛型函数签名的重载?
- reactjs - 如何在原子块内的文本输入中输入文本
- android - Android 垂直 RecyclerView 在 ConstraintLayout 内的高度变为 0;
- jquery - 带有下拉菜单的 Bootstrap 4 侧边栏,单击时保持打开
- git - 如何从所有未推送的 Git 提交中删除所有大于给定大小的文件?
- chisel - 如何表示 Vec 的指定索引范围?
- javascript - html页面中每张照片的下一个前一个锚点