axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ayman Yasin" <ya...@elm.com.sa>
Subject RE: [AXIS2] client to a dotnet service with policy
Date Mon, 20 Nov 2006 12:22:35 GMT
OK I tried modifying the main method of the client to the following:

 

    public static void main(java.lang.String args[]){

        try{

            VehiclePolicyStub stub =

                new VehiclePolicyStub();

 

           

            ServiceClient serviceClient=stub._getServiceClient();

            AxisService axisService=serviceClient.getAxisService();

            FileInputStream fis=new FileInputStream("c:\\policy.xml");

            Policy policy=PolicyEngine.getPolicy(fis);

            axisService.getPolicyInclude().setPolicy(policy);

 

 

 

                deleteVehicle(stub);

            

 

        } catch(Exception e){

            e.printStackTrace();

            System.err.println("\n\n\n");

        }

    }

 

 

I am still getting the same error. Is this the correct way to use the
policy file?

Thank you 

 

 

---------------------------------------------------------------------

---------------------------------------------------------------------

 

Hi

I have been given the following policy file for a dotnet web service
which i want to write a client to.

"

<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">

  <extensions>

    <extension name="usernameForCertificateSecurity"
type="Microsoft.Web.Services3.Design.UsernameForCertificateAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />

    <extension name="x509"
type="Microsoft.Web.Services3.Design.X509TokenProvider,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />

    <extension name="requireActionHeader"
type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />

    <extension name="usernameOverTransportSecurity"
type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />

  </extensions>

  <policy name="ClientPolicy">

    <usernameOverTransportSecurity />

    <requireActionHeader />

  </policy>

</policies>

"

first: is this kind of policy files supported in axis2?

second: how to make the client adheres to this policy file?

I have posted the following question in some forum:

" 

I am trying to access a dot net web service and i want to make use of
the policy file they gave me. i read that AXIS2 supports WS-Policy in
the client side but i still can not figure out how to tell the client to
use the file. I searched thoroughly for examples and searched through
different forums with no success. I found only similar questions with no
answer. if somebody could help it would be appreciated.

Thank you 

 

"

I got the following answer from Sanka Samaranayake :

"

When you codegen a Policy annotated WSDL, the policies are get included
in the stub. Hence you don't have to specify a separate Policy file.

 

But if you need to use a separate policy then you need to set them in
the AxisDescription object that you use in the ServiceClient and
OperationClient. 

 

e.g.

 

ServiceClient serviceClient = new ServiceClient();

OperationClient operationClient = serviceClient

.createClient(ServiceClient.ANON_OUT_IN_OP);

 

FileInputStream fis = new FileInputStream("path-to-policy.xml");

Policy servicePolicy = PolicyEngine.getPolicy(fis);

 

AxisService axisService = serviceClient.getAxisService();

axisService.getPolicyInclude().setPolicy(servicePolicy);

 

 

If you need more information please repost this to
axis-dev@ws.apache.org with a [AXIS2] subject prefix.

 

"

 

I can see no mention to the policy file in the WSDL so i want to use it
separately. I generated a proxy to the service using xmlbeans and wrote
the following client based on the getting started guide

"

public class Client{

 

    public static void main(java.lang.String args[]){

        try{

            VehiclePolicyStub stub =

                new VehiclePolicyStub();

 

           

                deleteVehicle(stub);

            

 

        } catch(Exception e){

            e.printStackTrace();

            System.err.println("\n\n\n");

        }

    }

 

    public static void deleteVehicle(VehiclePolicyStub stub){

        try{

            DeleteVehicleDocument reqDoc =
DeleteVehicleDocument.Factory.newInstance();

            DeleteVehicleDocument.DeleteVehicle req =
reqDoc.addNewDeleteVehicle();

                        

            

            

            Vehicle
vehicle=VehicleDocument.Vehicle.Factory.newInstance();

            

 
vehicle.setVehicleRegTypeCode((short)2);

 
vehicle.setVehiclePlateNumber((short)777);

                                    vehicle.setVehiclePlateText1("a");

                                    vehicle.setVehiclePlateText2("b");

                                    vehicle.setVehiclePlateText3("c");

                                    

            req.setVehicle(vehicle);

 

            DeleteVehicleResponseDocument res =

                stub.DeleteVehicle(reqDoc);

 

 
System.err.println(res.getDeleteVehicleResponse().getDeleteVehicleResult
());

        } catch(Exception e){

            e.printStackTrace();

            System.err.println("\n\n\n");

        }

    }

}

 

"

 

I get the following error when I run it indicating the missing security
options

"

org.apache.axis2.AxisFault: Security requirements are not satisfied
because the security header is not present in the incoming message.

"

I do not know how to integrate the code sanka suggested to use the
policy file manually into my client. can somebody help?

Thank you

 

 


Mime
View raw message