0
我想在創建Web服務時設置空目標名稱空間。這裏是例子。我的服務是這樣的:如何在Web服務中配置空的targetNamespace?
package com.example;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class SampleService
{
@WebMethod
public void sampleMethod()
{
}
}
定義的那樣,它接受看起來像這樣的請求(請注意考試命名空間聲明):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:exam="http://example.com/">
<soapenv:Header/>
<soapenv:Body>
<exam:sampleMethod/>
</soapenv:Body>
</soapenv:Envelope>
我想配置Web服務接受看起來像這樣的請求(沒有命名空間):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sampleMethod/>
</soapenv:Body>
</soapenv:Envelope>
我試圖將targetNamespace設置爲空的stri ng,但這並不奏效 - 它只是默認爲考試命名空間。
@WebService(targetNamespace="")
我使用Apache CXF(3.1.0),以公開服務:
<bean id="sampleService" class="com.example.SampleService" />
<jaxws:endpoint id="sampleServiceWs" implementor="#sampleService"
address="/SampleService" publish="true">
</jaxws:endpoint>