4 Replies Latest reply on Apr 8, 2014 11:08 AM by 1488196

    using createProject function from primavera Webservices

    1488196

      hello,

      I am trying to do integration between primavera and unifier via webservices

      I am using Eclipse IDE for calling the function from both application webservices.

       

       

      For unifier webservices i added a client in Eclipse and i used the function getProjectshellLIst in which i give the parameters and get the result in XML format

      but the issue i am facing is when i am trying to use the createProject function of primavera in Eclipse
      it is asking me createProjects(createProjects16) which is a class but i dont know where should i give the required parameters so that the project gets created in primavera

       

      plz help me with it or provide any other option i can use to integrate these to using webservices

        • 1. Re: using createProject function from primavera Webservices
          Berkhan Dipso

          You need to find p6ws-jaxws-client.jar

           

          It should be under P6 Enterprise install files

          1 person found this helpful
          • 2. Re: using createProject function from primavera Webservices
            1488196

            Hi,

            Thanks for responding.

            I have already added p6ws-jaxws-client.jar

            I have wriiten code for Username token Authentication for which i am referring the oracle documentation

            LINK:Invoking Primavera Web Services Synchronously from Java

            but then i am getting some error

            =========================================CODE===========================================

            public class test {

              public static void main(String[] args)throws Exception {

              URL wsdlURL = new URL("http:/host:port/p6ws/services/ActivityService?wsdl");

               ActivityService service = new ActivityService(wsdlURL);

               ActivityPortType port = service.getActivityPort();

            org.apache.cxf.endpoint.Client client = ClientProxy.getClient(port);

            org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

            Map outProps = new HashMap();

              outProps.put(WSHandlerConstants.ACTION, "UsernameToken Timestamp");

              outProps.put(WSHandlerConstants.USER, "admin");

              outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);

              outProps.put(WSHandlerConstants.USERNAME_TOKEN,ClientPasswordCallback.class.getName());  

              //Set the properties on the interceptor

              WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);

              cxfEndpoint.getOutInterceptors().add(wssOut);

              List fieldList = new ArrayList();

              fieldList.add(ActivityFieldType.fromValue("Id"));

              fieldList.add(ActivityFieldType.fromValue("RemainingDuration"));

              List<Activity> actList = port.readActivities(fieldList, null, null);

              System.out.println("Activity ObjectId Is " + actList.get(0).getObjectId());

              System.out.println("Activity RemainingDuration is " + actList.get(0).getRemainingDuration().getValue());

             

            ====================ERROR=============================================================

            Exception in thread "main" java.lang.ClassCastException: org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler cannot be cast to org.apache.cxf.frontend.ClientProxy

              at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:93)

              at com.test.test.main(test.java:63)

            =======================================================================================

            • 3. Re: using createProject function from primavera Webservices
              Berkhan Dipso

              Hi, I tried your code and below code is working for me;

               

              Please don't forget to sheck your P6 Web service settings : http://host:port/p6/admin.jsp

               

              Demo.java

               

              package com.prm;

               

               

              import java.net.MalformedURLException;

              import java.net.URL;

              import java.util.ArrayList;

              import java.util.HashMap;

              import java.util.List;

              import java.util.Map;

               

               

              import org.apache.cxf.frontend.ClientProxy;

              import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;

              import org.apache.ws.security.WSConstants;

              import org.apache.ws.security.handler.WSHandlerConstants;

               

               

              import com.primavera.ws.p6.activity.Activity;

              import com.primavera.ws.p6.activity.ActivityFieldType;

              import com.primavera.ws.p6.activity.ActivityPortType;

              import com.primavera.ws.p6.activity.ActivityService;

              import com.primavera.ws.p6.activity.IntegrationFault;

               

               

              public class Demo {

               

               

                public static void main(String[] args) throws IntegrationFault, MalformedURLException {

                URL wsdlURL = new URL("http://host:port" + ACTIVITY_SERVICE);

                ActivityService service = new ActivityService(wsdlURL);

                ActivityPortType port = service.getActivityPort();

                org.apache.cxf.endpoint.Client client = ClientProxy.getClient(port);

                org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

               

                Map outProps = new HashMap();

                outProps.put(WSHandlerConstants.ACTION, "UsernameToken Timestamp");

                outProps.put(WSHandlerConstants.USER, "admin");

                outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);

                //outProps.put(WSHandlerConstants.USERNAME_TOKEN,ClientPasswordCallback.class.getName());

                outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,ClientPasswordCallback.class.getName());

                //Set the properties on the interceptor

                WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);

                cxfEndpoint.getOutInterceptors().add(wssOut);

                

                 List fieldList = new ArrayList();

                 fieldList.add(ActivityFieldType.fromValue("Id"));

                 fieldList.add(ActivityFieldType.fromValue("RemainingDuration"));

                 String filter = "Id='A1000'";

                 List<Activity> actList = port.readActivities(fieldList, filter, null);

                 for (Activity act : actList) {

                 System.out.println("Activity ObjectId Is " + act.getObjectId());

                 System.out.println("Activity RemainingDuration is " + act.getRemainingDuration().getValue());

                 }

                }

               

               

                public static final String ACTIVITY_SERVICE = "/p6ws/services/ActivityService?wsdl";

               

               

              }

               

              ClientPasswordCallback.java

               

              package com.prm;

               

               

              import java.io.IOException;

               

               

              import javax.security.auth.callback.Callback;

              import javax.security.auth.callback.CallbackHandler;

              import javax.security.auth.callback.UnsupportedCallbackException;

               

               

              import org.apache.ws.security.WSPasswordCallback;

               

               

              public class ClientPasswordCallback implements CallbackHandler {

               

               

                @Override

                public void handle(Callback[] arg0) throws IOException,

                UnsupportedCallbackException {

                   WSPasswordCallback pc = (WSPasswordCallback) arg0[0];

                   pc.setPassword("passwd");

                }

               

               

              }

              • 4. Re: using createProject function from primavera Webservices
                1488196

                I resolved the issue, it was regarding the jar files i was using. I used the jar files as mentioned in the oracle doc and solved the issue

                Thanks Alot