Hi I have another question. Is there a need to generate stubs for services, given that stubs for services are present? I could not find a way to pass the token to generated web service stubs. However, I figured out how to use the stubs themselves
UserAdminStub s=new UserAdminStub();
ServiceClient serviceClient =s._getServiceClient();
option = serviceClient.getOptions();
option.setManageSession(true);
option.setProperty(
org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING,
token);
FlaggedName[] names=s.listAllUsers("*", 100);
for(FlaggedName name:names){
System.out.println(name.getItemDisplayName());
}
Is there a way to do this with generated code? or do the provided stubs
cover all services?
Also, I have not managed to login using the authenticate method with either
localhost or actual ip and credentials admin/admin. I used soapui to login
and obtain the session token, which I passed to the above web service,
which worked. Please let me know what mistake I am making in the login
proocess.
System.setProperty("javax.net.ssl.trustStore",
"C://wso2das-3.1.0/repository/resources/security/wso2carbon.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
LoginAdminServiceClient c=new LoginAdminServiceClient(backEndUrl);
String token=c.authenticate("admin","ädmin");
System.out.println("Token:"+token);
Invoking an admin service
Admin services are secured using common types of security protocols such
as HTTP basic authentication, WS-Security username token, and session based
authentication to prevent anonymous invocations. For example, the UserAdmin Web
service is secured with the HTTP basic authentication. To invoke a service,
you do the following:
1. Authenticate yourself and get the session cookie.
2. Generate the client stubs to access the back-end Web services.
To generate the stubs, you can write your own client program using the
Axis2 client API or use an existing tool like SoapUI
<http://www.soapui.org/> (4.5.1 or later) or wsdl2java.
The wsdl2java tool, which comes with WSO2 products by default hides all the
complexity and presents you with a proxy to the back-end service. The stub
generation happens during the project build process within the Maven POM
files. It uses the Maven ant run plug-in to execute the wsdl2java tool.
You can also use the Java client program given here
<https://svn.wso2.org/repos/wso2/people/asela/user-mgt/remote-user-api/4.2.X/>
to
invoke admin services. All dependency JAR files that you need to run this
client are found in the /lib directory.
On Wed, Jul 26, 2017 at 6:32 PM, Sagar Kapadia <[email protected]> wrote:
> Hi,
>
> I used this tutorial
> https://docs.wso2.com/display/DAS300/Calling+Admin+Services+from+Apps
>
> I am facing the following issues in importing the WSDL files and
> generating the code
> I get the following error message when I call
> wsimport AuthenticationAdmin.xml
>
> [ERROR] missing required attribute "message" of element "wsdl:output"
>
>
> Failed to parse the WSDL.
>
> I could not fix this issue.
>
> In another wsdl file "UserAdmin", I got multiple errors,
> [ERROR] operation "" has an invalid style
> which I fixed as follows
> https://stackoverflow.com/questions/12155114/generating-
> stubs-with-jax-ws-fails
> I added <wsdl:output message="tns::<OperationName>Response"> and also
> corresponding
> <wsdl:message name="<NameofMessage>">
>
> I was able to generate code for the UserAdmin sevice, but not for
> AuthenticationAdmin Service
>
> By the way the reason I tried to generate code for the Autherntication
> Service is that login fails without any exception . The token returned is
> null.
> I am sharing a link to the source code [Netbeans project] for the web
> service client and the the modified wsdl files I am using
>
>
> Link to the source
> https://drive.google.com/open?id=0BwqZCw5oc2rwcmJGTllNbEo2U00
>
>
> The help I require is primarily with the login functionality, because its
> failing. Also, is the manner I am trying to fix the wsdls correct? [Adding
> wsdl:output with message]
>
>
> Sincerely
> Sagar
>
LoginAdminServiceClient.java
Description: Binary data
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
