Reputation: 4579
I am using curl
to write the following in a windows command prompt:
curl -i -H "Content-Type:application/xml" -d "<test/>" -X PUT "http://localhost:9092/restapi"
My application has the following code:
public class RestAPI implements Provider<Source>
{
public static void main(String[] args)
{
Endpoint.publish(url, new RestAPI());
}
@Resource
private WebServiceContext wsContext;
@Override
public Source invoke(Source request)
{
if (wsContext == null)
throw new RuntimeException("dependency injection failed on wsContext");
MessageContext msgContext = wsContext.getMessageContext();
switch (((String) msgContext.get(MessageContext.HTTP_REQUEST_METHOD)).toUpperCase().trim())
{
case "PUT":
return processPut(msgContext, request);
'etc.
}
}
@Override
protected Source processPut(MessageContext msgContext, Source request)
{
// get the XML as a String
Transformer transformer;
try
{
transformer = TransformerFactory.newInstance().newTransformer();
StringWriter stringWriter = new StringWriter();
transformer.transform(request, new StreamResult(stringWriter));
System.out.println(stringWriter.toString());
}
catch (TransformerException | TransformerFactoryConfigurationError e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return request;
}
}
The output I see from the System.out.println
is as follows:
<?xml version="1.0" encoding="UTF-8"?><test xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"/>
At what point was the SOAP namespace added, and how can I remove it? (I'm creating a REST API, not a SOAP one)
Upvotes: 0
Views: 67
Reputation: 8868
You are using the JAX-WS
for the implementation of services - it is for building XML SOAP
services. So SOAP namespaces will be added automatically. If you plan to build REST services use JAX-RS implementation libraries like Jersey
Upvotes: 1