简体   繁体   中英

javax.xml.ws.Service could not read wsdlDocumentationLocation which is declare as URL('file:Authentication.wsdl')

My Java servlet, developed with JDeveloper 11g R2 and deployed on a WebLogic Server 10.3.6, needs to communicate with a specific WebService developed by a tiers company.

The javax.xml.ws.Service is created with wsdlDocumentLocation as a URL ( 'file:Authentication.wsdl' ).

Everything works fine on my server where the FireWall is disabled.

But on the customer server, I get the following error:

file:Authentication.wsdl 
Jan 22, 2016 9:27:32 AM weblogic.wsee.jaxws.spi.WLSProvider createServiceDelegate WARNING: Could not read WSDL Definition from URL wsdlDocumentLocation: 2 counts of InaccessibleWSDLException. 
Jan 22, 2016 9:27:32 AM weblogic.wsee.jaxws.spi.WLSServiceDelegate addWsdlDefinitionFeature SEVERE: Failed to create WsdlDefinitionFeature for wsdl location: file:Authentication.wsdl, error: com.sun.xml.ws.wsdl.parser.InaccessibleWSDLException, message: 2 counts of InaccessibleWSDLException.

I suspect the firewall on the customer server to block the access to the file Authentication.wsdl ?

I'm not sure but, for what I understand, using a URL with file: point to a local file accessed by some network protocol? Am I right?

If it's true, can you explain me what type of rules I should set in my firewall (Linux) to give access to this local file?

Does file:Authentication.wsdl means http://localhost:Authentication.wsdl or something like http://localhost/myServletContext/Authentication.wsdl ?

I can not figure out what I need to do to solve this issue.

I did futher tests and display informations about the URL objet. For new URL('file:/tmp/Authentication.wsdl'), getPort() returns -1, getHost() returns nothing and getPath() returns /tmp/Authentication.wsdl.

My Authentication.wsdl is inside my jar file which I use in my war file.

“file:Authentication.wsdl” is not a network protocol. It just refers to a plain old file name, on the same system.

It fails because your Authentication.wsdl is not actually a file. It's an entry in a .jar file, which I assume is on the classpath (as all .jar files in a .war file's WEB-INF/lib structure are). For this reason, a file: URL will never work in a production environment. No one distributes Java applications in unarchived form (for a number of good reasons).

An entry which is in the classpath is known as a resource. The correct way to access such data is with the Class.getResource method, which scans the classpath for the requested entry:

URL wsdlLocation = MyServlet.class.getResource("Authentication.wsdl");

Note, however, that this will look for Authentication.wsdl in the same package as your class. If your Authentication.wsdl is in the root of your archive, you could alter the string argument to find it—but you shouldn't. Placing resources in the root of an archive is very much like placing files in the root of the C: drive; it carries a risk of conflict with the multitude of other libraries in the classpath. That's why Class.getResource assumes, by default, that your file is in a directory that matches the Class object's package structure.

Meaning, if your servlet class is in the com.example.myapp package, Authentication.wsdl should be in the .jar file as com/example/myapp/Authentication.wsdl .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM