cancel
Showing results for 
Search instead for 
Did you mean: 

Consume a PI webservice in Java class

Former Member
0 Kudos


Hi Experts,

I need to comsume a Webservice given by PI in Java class.

Here is what i did:

1. PI person gave me a WSDL file test.wsdl

2. Axis I converted WSDL to stubs or Java classes

3. Stored the WSDL in a particular path on my PC

3. wrote a Java class to invoke this in Eclipse.

         QName SERVICE = new QName("https://xyz.com/XI/xyz_LOCAL/SCM", "MI_InboundWSService");

       

         URL url = null;

         try {

             url = new URL("file:/C:/out/MI_InboundWS.wsdl");

         } catch (MalformedURLException e) {

             java.util.logging.Logger.getLogger(MIInboundWSService.class.getName())

                 .log(java.util.logging.Level.INFO,

                      "Can not initialize the default wsdl from {0}", "file:/C:/out/MI_InboundWS.wsdl");

         }

        

        

        

         //MIInboundWSService service = new MIInboundWSService(url);    

             

         Service service = Service.create(url, SERVICE);

        

         MIInboundWS client = service.getPort(MIInboundWS.class);   

             

         DTSampleWS mtSampleWs = new DTSampleWS();

        

         mtSampleWs.setInput1("test by Vaibhav !!");

        

         client.miInboundWS(mtSampleWs);  

This is working, PI is able to get this data.

The issue is, WSDL is created in Development PI server with target link as below in the WSDL:

<soap:address location="http://server:50400/XISOAPAdapter/MessageServlet?channel=:DS3_SAP_Sourcing:DS3_SAP_Sourcing_SOAP_Sen..." xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>

So now for Quality and Prod, PI has to again create a seperate WSDL with respective target link in it.

As if you see in the code we are using WSDL and WSDL has Development link hardcoded.

Is there any way we can use a generic WSDL and pass the target link explicity ? or How can we manage in Quality and Prod without developing new WSDL.

Thanks a ton.

Accepted Solutions (1)

Accepted Solutions (1)

Ryan-Crosby
Active Contributor
0 Kudos

Hi Vaibhav,

Another option would be to take the WSDL generated in your development environment and manually insert additional endpoint bindings with different names based on your system/port/naming conventions.  Then for the client side if you add an application.properties file then each system in the landscape would be able to determine which binding is of interest so the application will connect to the right PI environment.

Regards,

Ryan Crosby

Former Member
0 Kudos

Thanks Ryan.

According to your suggestion, i created 3 endpoints (MI_InboundWSService, MI_InboundWSService_Q, MI_InboundWSService_P) in the same WSDL pointing to diff URL.

and then using

QName SERVICE = new QName("https://xyz.com/XI/xyz_LOCAL/SCM", "MI_InboundWSService");

or

QName SERVICE = new QName("https://xyz.com/XI/xyz_LOCAL/SCM", "MI_InboundWSService_Q");

or

QName SERVICE = new QName("https://xyz.com/XI/xyz_LOCAL/SCM", "MI_InboundWSService_P");

Regards,

Vaibhav

Answers (3)

Answers (3)

Former Member
0 Kudos

THe target link is not correct to call the PI SOAP Adapter. Please ask your PI colleagues to get the correct URL. In case of an Integrated Configuration they can generate a WSDL directly from within the Integrated Configuration. In case of a classical PI scenario they can generate it from the respective Sender Agreement. And please take in mind that all that stuff works only, if you use a FQDN like hugo.john.com:50400/....

Additionally take care of the difference between http and https call. If https is not configured in PI that URL will deliver you "nothing" ....

HOope this helps ...

REgrads, Volker

former_member184720
Active Contributor
0 Kudos

Hi Vaibhav- No need to generate a separate wsdl in each environment as long as the objects are same in all systems.

You just need to change the host and port in the endpoint URL

Former Member
0 Kudos

Hi Vaibhav,

Declare a variable and pass the QA/Prod ip and port.

Replace the server:50400 on wsdl with the variable before calling the URL in Java code.

Give it a try, you can reuse the code in QA/Prod by passing the QA/Prod IP and port.

Regards,

Pranav