Reputation: 668
I have a Maven project and am successfully connected to an insecure web service that has been created with WSO2. When the security is enabled, how do I pass the credentials, namely the Username and Password, to connect to the service?
Firstly, can I do it quickly by introducing the Username and Password in the Java code itself?
Do I have to generate a certificate like I've seen in a few of the articles or is there any other way to get this done?
My pom.xml
has the following entry
<execution>
<id>getTestService</id>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<unpackClasses>true</unpackClasses>
<databindingName>xmlbeans</databindingName>
<packageName>com.test.esb</packageName>
<wsdlFile>http://test:8080/services/getTestService?wsdl</wsdlFile>
<syncMode>sync</syncMode>
</configuration>
</execution>
and in my Java class, I am calling the service with the below code.
final TestServiceStub testStub = new TestServiceStub();
final TestServiceDocument testDoc =
TestServiceDocument.Factory.newInstance();
final TestService testReq = TestService.Factory.newInstance();
...
testDoc.setTestService(testReq);
testStub.TestService(testDoc);
Upvotes: 0
Views: 98