Forgot to mention: We’re using CXF 3.5.5 and Java 8.

-Dustin King


From: Dustin King<mailto:dustin.k...@xatorcorp.com.INVALID>
Sent: Wednesday, February 22, 2023 10:47 AM
To: users@cxf.apache.org<mailto:users@cxf.apache.org>
Subject: XmlSchemaException when calling Service.getPort() while on private 
network

Hi,

We have a requirement to run our web service client and service in a network 
that’s not connected to the Internet, but when I do this I’m getting an 
XmlSchemaException on the client side when our code calls Service.getPort().  
It looks like it’s trying to get the XSD from w3.org, even though we have a 
local copy.  On the server side we were able to fix this by setting the schema 
location before setting the factory bean’s port. But on the client side, it 
seems to require already having the port (BindingProvider) because the methods 
I would call are BindingProvider methods.

For example, the simplest solution would seem to be just turning off schema 
validation, but that’s a method call on the port itself, which would require 
having the port:

deviceServicePort.getRequestContext().put("schema-validation-enabled", false);
// not sure if it’s supposed to be the string or Boolean literal false here, 
examples vary.

I’ve also tried to see if I could set some kind of global configuration before 
trying to get the port, e.g.:

new 
JaxWsProxyFactoryBean().getServiceFactory().setSchemaLocations(Collections.singletonList("xsd/ws-addr.xsd"));
BindingProvider deviceServicePort = (BindingProvider) 
deviceService.getDevicePort();

But that doesn’t seem to do anything.  Any help would be appreciated!

Here’s our full stack trace:

org.apache.ws.commons.schema.XmlSchemaException: Unable to locate imported 
document at 
'https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2006%2F03%2Faddressing%2Fws-addr.xsd&data=05%7C01%7Cdustin.king%40xatorcorp.com%7C5613c4b4bc3247ff40cd08db14ec1639%7C0f19117da7f047319c102096da2ffaa2%7C0%7C0%7C638126776774138153%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XB5gJQHeJdQZj2309b6l%2FBMum7CZ4l%2FG8pvPIG7K93Q%3D&reserved=0',
 relative to 'schema5.xsd'.
        at 
org.apache.cxf.catalog.CatalogXmlSchemaURIResolver.resolveEntity(CatalogXmlSchemaURIResolver.java:76)
        at 
org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:682)
        at 
org.apache.ws.commons.schema.SchemaBuilder.handleImport(SchemaBuilder.java:536)
        at 
org.apache.ws.commons.schema.SchemaBuilder.handleSchemaElementChild(SchemaBuilder.java:1524)
        at 
org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:656)
        at 
org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:154)
        at 
org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:509)
        at 
org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:495)
        at 
org.apache.cxf.common.xmlschema.SchemaCollection.read(SchemaCollection.java:133)
        at 
org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:193)
        at 
org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:97)
        at 
org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:415)
        at 
org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:87)
        at 
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:469)
        at 
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:693)
        at 
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:529)
        at 
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:262)
        at 
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
        at 
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
        at 
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
        at 
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:158)
        at 
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
        at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:492)
        at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:358)
        at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:349)
        at javax.xml.ws.Service.getPort(Service.java:119)
        at 
org.onvif.ver10.device.wsdl.DeviceService.getDevicePort(DeviceService.java:61)
        at 
com.xator.cuas.onvif.override.OnvifDeviceOverride.init(OnvifDeviceOverride.java:128)
        at 
com.xator.cuas.onvif.override.OnvifDeviceOverride.<init>(OnvifDeviceOverride.java:94)
        at 
com.xator.cuas.onvif.override.OnvifDeviceOverride.<init>(OnvifDeviceOverride.java:109)
        at 
com.xator.cuas.onvif.OnvifTransceiver.lambda$new$0(OnvifTransceiver.java:106)
        at java.lang.Thread.run(Thread.java:748)

Here’s the relevant code in DeviceService, which is just a subclass of Service:

public class DeviceService extends javax.xml.ws.Service {
…
    @WebEndpoint(name = "DevicePort")
    public Device getDevicePort() {
        return super.getPort(DevicePort, Device.class);
    }
…
}


Thanks in Advance!

-Dustin King


Reply via email to