I've got a bundle which needs to communicate with a web service. The client was generated using Apache CXF, the WSDL of the web service is a local file, because the target system doesn't host the WSDL.
How can I integrate the WSDL into my OSGi bundle? Currently the web service client points to a file path of the WSDL which is pretty unuseful for deployment. Is there any way I can put the WSDL into the OSGi bundle? I tought about the resources folder, but there is none in my OSGi bundle.
This is the relevant part of the Java class:
@WebServiceClient(name = "WebService", targetNamespace = "http://company.com/target/namespace", wsdlLocation = "/tmp/WebService.wsdl")
public class WebService
After trying out this article, my code looks like this:
static {
URL url = null;
WebServiceException e = null;
try {
url = XI07D2B3188DService.class.getClassLoader().getResource("WebService.wsdl");
} catch (Exception ex) {
e = new WebServiceException(ex);
}
XI07D2B3188DSERVICE_WSDL_LOCATION = url;
XI07D2B3188DSERVICE_EXCEPTION = e;
}
The error with the not found WSDL is now gone, but I've got a new error:
500 XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
This is the beginning of my WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="SI_PARTNER_OPENTIMES_OA" targetNamespace="http://company.ch/xi/partnernet/partner" xmlns:p1="http://company.ch/xi/partnernet/partner" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation />
<wsp:UsingPolicy wsdl:required="true" />
<wsp:Policy wsu:Id="OP_SI_PARTNER_OPENTIMES_OA" />
I have already checked this question on SO. I tried changing it to UTF-16 but that didn't help. I also copied the content within Eclipse into a new file, but I've still got this error. Any idea?