I'm trying to set up empty target namespace when creating the Web Service. Here is the example. My service looks like this:
package com.example;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class SampleService
{
@WebMethod
public void sampleMethod()
{
}
}
Defined like that, it accepts requests that look like this (please note the exam namespace declaration):
<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>
I would like to configure the web service to accept the requests that look like this (without the namespace):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sampleMethod/>
</soapenv:Body>
</soapenv:Envelope>
I tried to set up the targetNamespace to the empty string, but that didn't work - it just defaulted to the exam namespace.
@WebService(targetNamespace="")
I'm using Apache CXF (3.1.0) to expose the service:
<bean id="sampleService" class="com.example.SampleService" />
<jaxws:endpoint id="sampleServiceWs" implementor="#sampleService"
address="/SampleService" publish="true">
</jaxws:endpoint>
To answer my question - I didn't find a way to set the empty targetNamespace, but I managed to leave out the request validation on my service, so that it now accepts the request with the namespace also. To do that, I used the @EndpointProperty
annotation on top of the service class:
package com.example;
import javax.jws.WebMethod;
import javax.jws.WebService;
import org.apache.cxf.annotations.EndpointProperty;
@WebService
@EndpointProperty(key = "soap.no.validate.parts", value = "true")
public class SampleService
{
@WebMethod
public void sampleMethod()
{
}
}