I have a WSDL file at the URL https://signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl . This is publicly accessable, however I have to use a VPN and when trying to access the URL while using the VPN I need to authenticate with my VPN-credentials. I know this may be strange, just know that while you may be able to access this withouth authentification, I do need to authenticate.
I use wsimport
to generate the Java-classes from the WSDL file. I successfully managed to do so after providing an authentication file via the xAuthfile
parameter :
My pom.xml:
<plugin>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<wsdlUrls>
<wsdlUrl>https://signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl</wsdlUrl>
</wsdlUrls>
<xauthFile>src/main/resources/myauthfile.auth</xauthFile>
<keep>true</keep>
<extension>true</extension>
<sourceDestDir>src/main/java/</sourceDestDir>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
</configuration>
</plugin>
Which results in the following command:
jaxws:wsimport args: [-keep, -s, 'C:\mypath\src\main\java', -d, 'C:\mypath\target\classes', -encoding, UTF-8, -extension, -Xnocompile, -Xauthfile, 'C:\mypath\src\main\resources\myauthfile.auth', "https://signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl"]
myauthfile.auth (Which contains my VPN-credentials) :
https://akooe\username:password@signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl
Aside from the other classes, this produces this webservice class:
@WebServiceClient(name = "PrimeSignWorkflowService", targetNamespace = "http://primesign.at/workflow/v1", wsdlLocation = "https://signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl")
public class PrimeSignWorkflowService
extends Service
{
private final static URL PRIMESIGNWORKFLOWSERVICE_WSDL_LOCATION;
private final static WebServiceException PRIMESIGNWORKFLOWSERVICE_EXCEPTION;
private final static QName PRIMESIGNWORKFLOWSERVICE_QNAME = new QName("http://primesign.at/workflow/v1", "PrimeSignWorkflowService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("https://signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
PRIMESIGNWORKFLOWSERVICE_WSDL_LOCATION = url;
PRIMESIGNWORKFLOWSERVICE_EXCEPTION = e;
}
public PrimeSignWorkflowService() {
super(__getWsdlLocation(), PRIMESIGNWORKFLOWSERVICE_QNAME);
}
.....
Which looks good. However, when I try to build my project, I get the error:
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'https://signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl'.: java.io.IOException: Server returned HTTP response code: 401 for URL: https://signatur.ak-ooe.at/primesign/services/workflowMTOM?wsdl
As you can see, it appears that even though I was able to generate the webservice from the URL by authenticating with my authfile, the generated webservice does not automatically use the same authentication, thus it cannot access the URL.
How do I solve this problem? Can I somehow add code to the generated webservice class so that it authenticates automatically?