Using a simple scenario, this article explains how to create a brokered web service in SAP XI 3.0. In Part II, I will describe how to consume this web service in a Web Dynpro Application.
Scenario:
- User requests Customer Details via a Web browser
- Data is sent through WebAS to SAP XI using a SOAP adapter
- The message is then synchronously sent to SAP R/3 system via RFC adapter, and a BAPI call is executed to get the Customer details
- The BAPI response is sent to the WebAS to fulfil the user request
This part of the article describes how to create web services in SAP XI while the Part II deals with using the WSDL file to expose the web service using Web Dynpro.
Prerequisites:
- Good knowledge of SAP XI 3.0 concepts
- Basic knowledge of Web Dynpro Applications
Repository:
1. Import the RFC function module BAPI_CUSTOMER_GETDETAIL2 from SAP R/3 system.
2. Define Interface Objects:
Data Types – ReqCustomerNo_DT and RespCustDetails_DT
Message Types – ReqCustomerNo_MT for data type ReqCustomerNo_DT and RespCustDetails_MT for data type RespCustDetails_DT
Message Interface – CDWS_MI (Outbound and Synchronous)
3. Define Mappings Objects
Request Mapping – Request_MM between ReqCustomerNo_MT and BAPI_CUSTOMER_GETDETAIL2
CustomerNumber to CUSTOMERNO
CompanyCode to COMPANYCODE
User-Defined function isNumeric is used to find out if the input contains only numbers or is alphanumeric. It returns true if the input string is all numeric. If the input string is numeric, function FormatNum is used to convert Customer Number to 10 digits and Company Code to 4 digits with leading zeros. If the input string is alphanumeric function toUpperCase converts the string to upper case.
Similarly, define response mapping – Response_MM between BAPI_CUSTOMER_GETDETAIL2.Response and RespCustDetails_MT
- CUSTOMERADDRESS.CUSTOMER => CustomerNumber
- CUSTOMERADDRESS.NAME => Name
- CUSTOMERADDRESS.STREET => Street
- CUSTOMERADDRESS.CITY => City
- CUSTOMERADDRESS.COUNTRY => Country
- RETURN.TYPE => MessageType
- RETURN.MESSAGE => ReturnMessage
Finally, define Interface Mapping – CDWS_IM between CDWS_MI and BAPI_CUSTOMER_GETDETAIL2 using the above message mappings and activate the objects
Directory:
1. Add a Business Service say SOAP_Service to your Configuration Scenario
2. Add the outbound interface CDWS_MI and a Communication Channel say, SOAP_Client (using the SOAP Adapter) to the sender tab of the service
3. Define the Sender Agreement using the above objects
4. Create Business Service for the R/3 System if not previously created and add a communication channel using RFC Adapter to it
5. Define Receiver Determination object with the R/3 system as receiver and activate the objects
Defining the Web Service:
Once all the objects are activated, we can proceed to define the web service.
1. In the Integration Directory choose the menu path Tools -> Define Web Service… and choose to Continue
2. Specify the URL in the format below and Continue. Party name will be blank in our case.
http://<host>:<J2EEport>/XISOAPAdapter/MessageServlet? channel=<party>:<service>:<channel>
3. Specify the receiver message interface details and Continue
4. Specify the sender details and choose to Continue
In our case both sender and receiver message interfaces will be same as we are using a synchronous interface
5. Verify the details in the next step and choose Finish. Save the generated WSDL file on your desktop
The WSDL file thus generated can be used to consume the web service in various ways, e.g. by wrapping it around a Java proxy and exposing that Java proxy object in an EJB web service or by importing the WSDL in a Web Dynpro or Microsoft .NET Application. I will describe the second approach using the Web Dynpro Application in Part II of this article.
Hi Riyaz,
really excellent detailed information provided by u.
Thaks for ur valuable information.
I have a SOAP -XI -ABAP Proxy scenario. On testing, it gives me the following error
XIServer
CO_TXT_OUTBINDING_ERROR
It goes on to say no standard agreement found for…
Any pointers on how to resolve this?
Where do you see this error? in target system or in XI?
Hi Riyaz,
First off, your blog is very helpful. Kudos to you for taking time to come up with it.
I followed your guide to a T but I always get an Unauthorized 401 error. I tried the PIISUER and PISUPER user but to no avail.
Can you point me in the right direction? I must’ve missed a configuration step or something.
Cheers.
HI Riyaz,
Very nice blog. In PI 7.1 there is tab called WSDL for every interface. If we are using WSDL , can we only use that one instead of creating this .
Although I see this when we use the URL instead of wsdl..!! Any thoughts..
Thanks
Harish
Requirement : Solutions for RFC to WebService..
Data Flow :
1. RFC call to WebService
2. WebService will serach concern record and will reply back to RFC
Suggest me complete roadmap for the scenario, as i m bit confused to use wether workout on java function for searching concern record from multiple webservices or anything else is possible.
Thanks and Regards,
You can very well make use of RFC adapter on sender side and a SOAP adapter on receiver side in SAP PI. Whenever you execute the RFC in your source system with appropriate destination, the web service call would get triggered via SAP PI.
HI Riyaz,
How can I “1. Import the RFC function module BAPI_CUSTOMER_GETDETAIL2 from SAP R/3 system.”?
The first point of your steps.
Thanks and Regards.
Fernando.
Hi Fernando,
See section “Import IDoc Interface from SAP System” at this link for steps to Import RFCs and IDocs in IR. Steps for importing IDoc and RFCs are the same.
Regards,
Riyaz
Hi Riyaz,
I’ve tried what you said but when I’m going to import from SLD and I have this error:
Unable to read software component versions from System Landscape Directory “ues90022:52000”
How can I solve this problem.
Thanks a lot.
Fernando.
The import of IDocs/RFCs has nothing to do with import from SLD. You can import IDoc/RFC metadata only after the SWC is visible in your IR.
If you are facing difficulties in importing SWC version, try clearing SLD cache using IR menu options.
If this does not help, it may indicate that the CIM Content in your SLD is not up-to-date. Ask you basis administrator to import the latest CIM Content (CIM Model file and CRDelta files) into SLD. SAP note 669669 would be useful.
Hi Riyaz,
I’m in the step 3. Define Mappings Objects in the IR.
How can I create a Request Mapping or a response mapping? I only have the option to create a Interface Mapping.
Thanks a lot.
Regards.
Fernando.
Hi Riyaz,
I’m creating the Request Mapping and I’would like to know “//write your code here” for the User-Defined function isNumeric.
Sorry but I’m new in this…
Thanks.
Fernando.
Hi again Riyaz,
I’m at (Directory) in step “5. Define Receiver Determination object with the R/3 system as receiver and activate the objects”.
I don´t know how to do this. Can you help me.
Your blog is very helpful…
Thanks.
Fernando.
Hi Fernando,
For step 5, check this link: https://www.riyaz.net/blog/xipi-configuration-using-integration-directory/.
In interface mapping, you will see two tabs (for request and response) at the bottom box where you specify mapping program name. This is true if you have a synchronous interface.
isNumeric UDF can be written in a number of ways like one below:
//str is the input String variable for the function
for (int i = 0; i < str.length(); i++) {
//If we find a non-digit character, return false.
if(!Character.isDigit(str.charAt(i)))
return false;
}
return true;
Hi Ryaz,
Thank you very much for your help.
I did what you said to me about isNumeric function but I have an error when I try to activate the object.
“incompatible types
found : boolean
required: java.lang.String
return false;”
I think the problem is that the function is defined for returning a String value, not a boolean, but I don´t konw who to change it.
Can you help me?
Thanks a lot.
Fernando.
Change the return statements as below wherever they appear in the UDF code:
return "false";
instead ofreturn false;
return "true";
instead ofreturn true;
This should help.
Hi Ryaz,
It worked, thanks a lot. (UDF code).
Now I have another problem (sorry for the repetition).
When I trie to test de Web Service, for example with XML SPY (to create and send SOAP request from the generated WSDL) I get this error:
“SOAP:Envelope xmlns:SOAP=”http://schemas.xmlsoap.org/soap/envelope/”>
SOAP:Server
Server Error
XIAdapter
ADAPTER.JAVA_EXCEPTION
<![CDATA[
com.sap.aii.af.mp.module.ModuleException: either no channelID specified or no channel found for the specified party, service, and channel name, MessageServlet(Version $Id: //tc/xi/645_VAL_REL/src/_adapters/_soap/java/com/sap/aii/af/mp/soap/web/MessageServlet.java#12 $)
at com.sap.aii.af.mp.soap.web.MessageServlet.doPost(MessageServlet.java:421)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)”
Sure that it means that I have something bad configurated, but, where?, what?
Thanks again for your help.
Waiting for your news.
Regards.
Fernando.
Hi again Ryaz,
I’ve solved the anteior problem “com.sap.aii.af.mp.module.ModuleException: either no channelID specified or no channel found for the specified party, service, and channel name, MessageServlet”, performing a full CPA Cache refresh using PIDIRUSER. (http://xxxxxxxxx:xxxx/CPACache/refresh?mode=full)
But now I have this problem (XML Spy)
XIProxy: INTERFACE_REGISTRATION_ERROR
Any pointers on how to resolve this?
Thank you very much.
Fernando.
Hi Ryaz,
Continuing with the anterior error, XIProxy: INTERFACE_REGISTRATION_ERROR…
Looking in the log files in RWB (Runtime Workbench in Integartion Monitoring PI) I’ve seen this message:
Received XI System Error. ErrorCode: INTERFACE_REGISTRATION_ERROR
ErrorText:
ErrorStack: For the interface implementation class is not registered (ABAP interface CDWS_MI Request Message, Request Message namespace http://mapfre.es/ws/Pruebas)
Can you point me in the right direction? I must’ve missed a configuration step or something.
Thanks a lot.
Thanks.
That’s a cunning answer to a cahllenigng question
Hi Riyaz
I am having a problem using the WSDL that is being generated.
I am importing it into ‘XML Transmitter’ and using this tool to generate a test message.
The message fails the Mapping in XI, with a RuntimeException in Message-Mapping:
“Cannot produce target element /ns1:BAPI_CUSTOMER_GETDETAIL2/CUSTOMERNO”
The message being posted into XI is:
1
1
I get the same error when I use the XI testing tool with this XML
When I generate a test message in XI, it looks like this:
…. which goes through the mapping ok.
Any ideas where I am going wrong?
To be more clear, the message being generated by the WSDL seems to be missing a namespace prefix. XI is expecting
ns0:ReqCustomerNo_MT xmlns:ns0=”http://consumeRFC”
but the WSDL is generating
ReqCustomerNo_MT xmlns:ns0=”http://consumeRFC”
…. any ideas please?
I am not able to see the complete message you posted. However, I guess it could be an issue with namespaces. Check the XML namespaces used in the message type definition. If you are not needing it, you can safely remove the namespace under XML namespace field in message type definition and test again. You might have to regenerate the WSDL.
Hi,
Where to check for the WSDL generated and the URL
Hi Riyaz,
Kindly help me in understaing basic conecpts of Web dynpro for Java/ABAP..
pls Send me a link of that.
Thanks
Jeevitha
Where is the UDF code for isNumeric? Can you please paste the code?
Thanks
When i tried to use my own URL as you suggested I am getting error executing the WSDL file in SOAP. Can you please help me and elaborate how to generate an URL.
Thanks in advance.
Vichu
This particular blog post XI/PI: Consuming XI Web Services using Web Dynpro – Part I, has got really excellent info and I actually discovered precisely what I
was basically searching for. Thanks.