wsimport is used to generate the JAX-WS service clients.

But the generated client stubs are already available for all the admin
services of WSO2. I suggest you use them. These work over Axis2 SOAP engine.

On Wed, Jul 26, 2017 at 11:49 PM, KasunG Gajasinghe <kas...@wso2.com> wrote:

>
> If you are trying to invoke via Java, then you can check the existing
> usage of UserAdminStub class here [1].
>
> These admin services are already used by the mgt console UI to invoke the
> back-end services. A trick I used to capture the soap envelope is the
> following. This does not work all the time. You can throw the dice and see.
>
> 1. Go to repository/components/plugins folder
> 2. Unzip the relevant jar bundle that that contain the service. UserAdmin
> service is in org.wso2.carbon.user.mgt_5.7.5.jar.
> 3. In there, open META-INF/services.xml file in there, and remove the
> following two lines
>
>     <parameter name="adminService" locked="false">true</parameter>
>     <parameter name="hiddenService" locked="false">true</parameter>
>
> 4. Zip it back, and restart the server.
>
> 5. Now go to, *Monitor* -> *Soap Tracer*, and enable it.
> 6. Do a user mgt UI operation and check the Soap Tracer.
>
> As I said, throw the dice and see. It may not work for you.
>
> [1] https://github.com/search?q=org%3Awso2+UserAdminStub&type=Code
>
> On Wed, Jul 26, 2017 at 11:11 PM, Sagar Kapadia <ks197...@gmail.com>
> wrote:
>
>> 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.htt
>> p.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 <ks197...@gmail.com>
>> 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-stub
>>> s-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
>>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
>
> *Kasun Gajasinghe*Associate Technical Lead, WSO2 Inc.
> email: kasung AT spamfree wso2.com
> linked-in: http://lk.linkedin.com/in/gajasinghe
> blog: http://kasunbg.org
> phone: +1 650-745-4499 <+1%20650-745-4499>, 77 678 0813
>
>



-- 

*Kasun Gajasinghe*Associate Technical Lead, WSO2 Inc.
email: kasung AT spamfree wso2.com
linked-in: http://lk.linkedin.com/in/gajasinghe
blog: http://kasunbg.org
phone: +1 650-745-4499, 77 678 0813
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to