SAP创建Web Service以及用ABAP调用
生活随笔
收集整理的這篇文章主要介紹了
SAP创建Web Service以及用ABAP调用
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
如果運(yùn)行
soamanager
打不開(kāi),網(wǎng)頁(yè)顯示
devaix
.zhongpin.com
,打開(kāi)
C
:\WINDOWS\system32\drivers\etc,
用記事本打開(kāi)
hosts
文件
,
在最后一行加上:
192
.168.2.24?devaix.zhongpin.
com
本次學(xué)習(xí)如何用 SAP 創(chuàng)建 web?service , 以及如何利用 ABAP 調(diào)用 Web?Service .
步驟:
1.? 創(chuàng)建一個(gè) RFC 函數(shù) Z_ADD ;
2.? 根據(jù)這個(gè)函數(shù)創(chuàng)建 Web?Service ,? 菜單 ’Utilities’ ->’More?Utilities’->’Create?Web?Service’->’From?the?Funciton?Module’; 輸入 Service? Definition:?ZWS_001 和描述;
一直點(diǎn) Continue , 直到完成,系統(tǒng)顯示對(duì)象已激活;
創(chuàng)建 Web?Service 的另一種方法是: SE80 -> 右擊函數(shù)組名稱 ->create-> web?service;
注意:這兩種方法大致相同,在完成時(shí),選中 ’Deploy?Service’ 。
3.? 激活該 Funciton;
4.?find?URL.SOAMANAGER,application?and?scenario?communication->single?service?administration, 在打開(kāi)的網(wǎng)頁(yè)中搜索 service :?Z_WS_001->apply->Open?WSDL?document?for?selected?binding-> 復(fù)制 wsdl 文件的地址作為 URL;
5.?SE80, 根據(jù)上面得到的 URL 創(chuàng)建 consumer , 得到 proxy?name :ZPRECO_Z_WS_001 , ’ZPRE’ 是前綴。
6.?CREATE??LOGIC??PORT.??SOAMANAGER ,創(chuàng)建邏輯端口,在打開(kāi)的網(wǎng)頁(yè)中搜索 consumer?proxy :?ZPRECO_Z_WS_001,( 最好是雙向搜索 )->apply->configurations->create?logic?port.
之后即可測(cè)試成功。
測(cè)試代碼如下:
report.
*-->這個(gè)proxy?class是在前面定義好的
data?proxy?type?ref?to?zpreco_z_ws_001.
*-->這兩個(gè)數(shù)據(jù)類型可以在proxy?class中的方法中找到(雙擊ZPRECO_Z_WS_001,進(jìn)入這個(gè)類的定義).
data:?ls_input??type?zprezadd,
??????ls_output? type?zprezadd_response.
start -of-selection.
*-->根據(jù)logical?port創(chuàng)建對(duì)象
?? try.
?????? create? object?proxy
???????? exporting
??????????logical_port_name? =?'LP01'.
???? catch?cx_ai_system_fault?.
?? endtry.
*-->調(diào)用web?service的方法
??ls_input -idata1?=?2.
??ls_input -idata2?=?4.
?? try.
?????? call?method?proxy-> zadd
???????? exporting
?????????? input??=? ls_input
???????? importing
?????????? output?=?ls_output.
???? catch?cx_ai_system_fault?.
???? catch?cx_ai_application_fault?.
?? endtry.
?? write:?ls_output-eresult.?
此時(shí)運(yùn)行該程序總會(huì)出現(xiàn)登陸框,安全設(shè)定的原因。
可以在邏輯端口中配置自己的賬號(hào)和密碼,步驟: SOAMANAGER ,在打開(kāi)的網(wǎng)頁(yè)中搜索 consumer?proxy :?ZPRECO_Z_WS_001 ,選擇邏輯端口 ->edit->consumer?security, 輸入自己的賬號(hào)和密碼即可。
本次學(xué)習(xí)如何用 SAP 創(chuàng)建 web?service , 以及如何利用 ABAP 調(diào)用 Web?Service .
步驟:
1.? 創(chuàng)建一個(gè) RFC 函數(shù) Z_ADD ;
2.? 根據(jù)這個(gè)函數(shù)創(chuàng)建 Web?Service ,? 菜單 ’Utilities’ ->’More?Utilities’->’Create?Web?Service’->’From?the?Funciton?Module’; 輸入 Service? Definition:?ZWS_001 和描述;
一直點(diǎn) Continue , 直到完成,系統(tǒng)顯示對(duì)象已激活;
創(chuàng)建 Web?Service 的另一種方法是: SE80 -> 右擊函數(shù)組名稱 ->create-> web?service;
注意:這兩種方法大致相同,在完成時(shí),選中 ’Deploy?Service’ 。
3.? 激活該 Funciton;
4.?find?URL.SOAMANAGER,application?and?scenario?communication->single?service?administration, 在打開(kāi)的網(wǎng)頁(yè)中搜索 service :?Z_WS_001->apply->Open?WSDL?document?for?selected?binding-> 復(fù)制 wsdl 文件的地址作為 URL;
5.?SE80, 根據(jù)上面得到的 URL 創(chuàng)建 consumer , 得到 proxy?name :ZPRECO_Z_WS_001 , ’ZPRE’ 是前綴。
6.?CREATE??LOGIC??PORT.??SOAMANAGER ,創(chuàng)建邏輯端口,在打開(kāi)的網(wǎng)頁(yè)中搜索 consumer?proxy :?ZPRECO_Z_WS_001,( 最好是雙向搜索 )->apply->configurations->create?logic?port.
之后即可測(cè)試成功。
測(cè)試代碼如下:
report.
*-->這個(gè)proxy?class是在前面定義好的
data?proxy?type?ref?to?zpreco_z_ws_001.
*-->這兩個(gè)數(shù)據(jù)類型可以在proxy?class中的方法中找到(雙擊ZPRECO_Z_WS_001,進(jìn)入這個(gè)類的定義).
data:?ls_input??type?zprezadd,
??????ls_output? type?zprezadd_response.
start -of-selection.
*-->根據(jù)logical?port創(chuàng)建對(duì)象
?? try.
?????? create? object?proxy
???????? exporting
??????????logical_port_name? =?'LP01'.
???? catch?cx_ai_system_fault?.
?? endtry.
*-->調(diào)用web?service的方法
??ls_input -idata1?=?2.
??ls_input -idata2?=?4.
?? try.
?????? call?method?proxy-> zadd
???????? exporting
?????????? input??=? ls_input
???????? importing
?????????? output?=?ls_output.
???? catch?cx_ai_system_fault?.
???? catch?cx_ai_application_fault?.
?? endtry.
?? write:?ls_output-eresult.?
此時(shí)運(yùn)行該程序總會(huì)出現(xiàn)登陸框,安全設(shè)定的原因。
可以在邏輯端口中配置自己的賬號(hào)和密碼,步驟: SOAMANAGER ,在打開(kāi)的網(wǎng)頁(yè)中搜索 consumer?proxy :?ZPRECO_Z_WS_001 ,選擇邏輯端口 ->edit->consumer?security, 輸入自己的賬號(hào)和密碼即可。
總結(jié)
以上是生活随笔為你收集整理的SAP创建Web Service以及用ABAP调用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SAP用Function发布供外部调用的
- 下一篇: 从sap xi生产wsdl文件,客户端怎