10 Replies Latest reply: Apr 1, 2009 8:18 AM by Danail Branekov RSS

How to consume SAP PI web service in CE 7.1?

Jayson Shai
Currently Being Moderated

Hi all,

 

I have a web service defined in XI/PI (process integration), and want to consume it in NWDS CE 7.1. I did some research and there is a sap help http://help.sap.com/saphelp_nwce10/helpdata/en/46/935a636110581de10000000a1553f7/frameset.htm regarding this. However this just does not apply to my case, the corresponding classes referred to in the help just does not exist in my case.

 

What I did:

1) Import the wsdl into my java project

2) Generate ws client based on the wsdl (Java standalone, not java proxy as EJB)

3) After the client generation, I have four java classes:

a) public interface SI_CounterReading_Out_A extends java.rmi.Remote

   b) public class SI_CounterReading_Out_ABindingStub extends org.apache.axis.client.Stub implements SI_CounterReading_Out_A

   c) public interface XI_6F873345De7D38C48610E2F078F60406_Service extends javax.xml.rpc.Service

   d) public class XI_6F873345De7D38C48610E2F078F60406_ServiceLocator extends org.apache.axis.client.Service implements XI_6F873345De7D38C48610E2F078F60406_Service

4) I crated a java class to call the ws client by using the four classes. However I couldn't get it work.

 

The code I have:

String endPoint = "http://myendpoint";

SI_CounterReading_Out_ABindingStub stub = new SI_CounterReading_Out_ABindingStub();

stub._setProperty(stub.USERNAME_PROPERTY,"myuser");

stub._setProperty(stub.PASSWORD_PROPERTY, "mypassword");

stub._setProperty(stub.ENDPOINT_ADDRESS_PROPERTY, endPoint);

stub.SI_CounterReading_Out_A(input);

 

I ran the program, no exception, but apparently the ws was not called.

 

I also tried the code;

SI_CounterReading_Out_A port = service.getHTTP_Port();

javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider)port;

Map<String,Object> context = bp.getRequestContext();

context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);

context.put(BindingProvider.USERNAME_PROPERTY,"jxiao");

context.put(BindingProvider.PASSWORD_PROPERTY,"maianji53");

port.SI_CounterReading_Out_A(input);

 

I got exception taht the class cast javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider)port;does not work.

 

Can somebody tell me how to consume the ws in NWDS CE 7.1É

 

Thanks

 

  • Re: How to consume SAP PI web service in CE 7.1?
    Jayson Shai
    Currently Being Moderated

    I would be surprised taht nobody has idea about this.

  • Re: How to consume SAP PI web service in CE 7.1?
    murali krishna reddy
    Currently Being Moderated

    HI

     

      Go through this blog ,  consuming PI webservices

     

           /people/daniel.wroblewski/blog/2005/02/20/portal-sp9-portal-activity-report

    • Re: How to consume SAP PI web service in CE 7.1?
      Jayson Shai
      Currently Being Moderated

      Hi Alka,

       

      thanks for reply.

      However this blog presents the same way as the SAP Help which just does apply to my case.

       

      1) I can't not use SAP netweaver as ws runtime when generating the ws client. Otherwise it say, SAP netweaver does not support my project.

      2) In my generated java class I only have service.getHTTP_Port();  instead of service.getMyOperationPort();

      3) When I try to class cast javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider)port; I got runtime exception saying it can not be casted.

       

      In webdynpro, I guess you use adaptive web service model where the ws client is generated by the WD runtime, not sure if it's the Java ws client generation issue towards PI web service.

       

      FRUSTRATED!

       

      Jayson

  • Re: How to consume SAP PI web service in CE 7.1?
    Danail Branekov
    Currently Being Moderated

    Hey Jayson,

     

    The fact that the class SI_CounterReading_Out_ABindingStub extends org.apache.axis.client.Stub makes me think that you have generated your web service client using the Apache Axis web service runtime. In this case the proxy generated is a JAX-RPC one. This is also the reason that you cannot cast your port to javax.xml.ws.BindingProvider

     

    In order to generate a client using the SAP toolset you will have to choose the "SAP Netweaver" WS runtime via clicking on the "Web service runtime" link on the first wizard page. the AXIS runtime is the default one in case you skipped one of the prerequisites step described at http://help.sap.com/saphelp_nwce10/helpdata/en/45/100c6be9f87201e10000000a155369/content.htm:

     

    The application server and Web service runtime are set in the SAP NetWeaver Developer Studio from Window  ®  Preferences  ®  Web Services  ®  Server and Runtime. In the Server field, choose SAP Server, and in the Web service runtime, choose SAP NetWeaver.

     

    Once you generate the client using the SAP Netweaver runtime, you should be able to consume the service using the JAX-WS means as described in the help.

     

    Regards, Danail

     

    • Re: How to consume SAP PI web service in CE 7.1?
      Jayson Shai
      Currently Being Moderated

      Hi Daniel,

       

      thanks for reply.

      However as you see in my last post, I got error while specifying SAP netweaver as ws runtime. Do you know what that could be?

       

      Thanks

      jayson

      • Re: How to consume SAP PI web service in CE 7.1?
        Danail Branekov
        Currently Being Moderated

        >

        Jayson wrote:

         

        > However as you see in my last post, I got error while specifying SAP netweaver as ws runtime

        >

        > Thanks

        > jayson

         

        This is really strange... Could you check the ws client wizard's first page settings? Do not rely on the default values and do make sure that everything is set correctly - the server, the WS runtime and the client project.

         

        It would be also helpful if you could attach a shot of the client wizard first page right before you press "Next"

         

        Regards, Danail

        • Re: How to consume SAP PI web service in CE 7.1?
          Jayson Shai
          Currently Being Moderated

          Hi Danail,

           

          I found out why I couldn't use SAP Netweaver as ws runtime, it's because I used the default JDK version 6.0 and obviously Netweaver only supports 5.0, after I changed it to JDK 5.0, I am ok.

           

          So I could code the ws client like way you guys (also sap help) pointed. However when I run it I got exception:

           

          javax.xml.ws.soap.SOAPFaultException: Server Error

               at com.sap.engine.services.webservices.espbase.client.bindings.impl.JAXWSUtil.processFault(JAXWSUtil.java:341)

               at com.sap.engine.services.webservices.espbase.client.bindings.impl.SOAPTransportBinding.call_SOAP(SOAPTransportBinding.java:987)

               at com.sap.engine.services.webservices.espbase.client.bindings.impl.SOAPTransportBinding.callWOLogging(SOAPTransportBinding.java:703)

               at com.sap.engine.services.webservices.espbase.client.bindings.impl.SOAPTransportBinding.call(SOAPTransportBinding.java:649)

               at com.sap.engine.services.webservices.espbase.client.jaxws.core.WSInvocationHandler.processTransportBindingCall(WSInvocationHandler.java:152)

               at com.sap.engine.services.webservices.espbase.client.jaxws.core.WSInvocationHandler.invokeSEISyncMethod(WSInvocationHandler.java:117)

               at com.sap.engine.services.webservices.espbase.client.jaxws.core.WSInvocationHandler.invokeSEIMethod(WSInvocationHandler.java:83)

               at com.sap.engine.services.webservices.espbase.client.jaxws.core.WSInvocationHandler.invoke(WSInvocationHandler.java:64)

               at $Proxy16.siCounterReadingOutA(Unknown Source)

               at ca.pi.TestCounterReading.callWebService1(TestCounterReading.java:73)

               at ca.pi.TestCounterReading.main(TestCounterReading.java:32)

           

           

          The code to call the ws:

           

          SICounterReadingOutA port = service.getHTTP_Port();

          javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider)port;

           

          Map<String,Object> context = bp.getRequestContext();

           

          context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);

          context.put(BindingProvider.USERNAME_PROPERTY,"myuser");

          context.put(BindingProvider.PASSWORD_PROPERTY,"mypwd");

                          

          port.siCounterReadingOutA(input);

           

           

          Do you see anything wrong here?

           

          BTW, I could reach the endpoint in IE, so server or connection should not be the issue.

           

          Thanks

          Jayson

  • Re: How to consume SAP PI web service in CE 7.1?
    Currently Being Moderated

    Sorry for this, I had this window opened for days and I gave a response without knowing that it has been already answered. I saw it after the refresh of the form.

    Sorry for repeating

    -


     

    Hi Jason,

     

    It seems to me that you are using wrong runtime and server settings.

    As you mention above, you have generated some Java classes that have "extends org.apache.axis.client.Stub" and "extends org.apache.axis.client.Service" in their code. This makes me think that you are using the default Apache Axis settings.

     

    As it is written in the prerequisites section of the documents, you have to use SAP Server and SAP NetWeaver Runtime to generate correct proxies.

     

    "The application server and Web service runtime are set in the SAP NetWeaver Developer Studio from Window >> Preferences >> Web Services >> Server and Runtime. In the Server field, choose SAP Server, and in the Web service runtime, choose SAP NetWeaver."

     

    http://help.sap.com/saphelp_nwce10/helpdata/en/45/100c6be9f87201e10000000a155369/frameset.htm

     

    I hope this helps.

    Best regards,

    Nikolay

     

    Edited by: Nikolay Kanchev on Mar 30, 2009 6:21 PM

Actions