前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >最详细的使用soapui消费Web service的教程

最详细的使用soapui消费Web service的教程

作者头像
Jerry Wang
发布2019-06-01 22:25:49
2.1K0
发布2019-06-01 22:25:49
举报

本文就以SAP Cloud for Customer的web service消费这个需求为例,来讲解soapui这个工具的使用步骤。

使用soapui消费web service,最简单的方式是在soapui里直接导入web service的WSDL文件。

为此,我们需要先拿到SAP C4C标准web service的WSDL文件。

  1. Go to workcenter Administrator, then Input and Output management->Service Explorer, you can get a list of all standard inbound services here.

在administator工作中心的input and output management里找到想消费的web service:

clipboard1
clipboard1

点击超链接,把它的WSDL文件下载下来。

If you are working in 1605, you can find a list of all standard web services from SAP help:

clipboard2
clipboard2

Since I would like to query Opportunity data, I choose QueryOpportunityIn, and click “Show full documentation”:

clipboard3
clipboard3

The documentation tells me how to fill the request detail in SoapUI.

  1. Download and install SoapUI. Create a new SOAP project by loading the WSDL downloaded from previous step.

下载安装soapui,此处导入第一步下载的WSDL文件。

clipboard4
clipboard4

Suppose I would like to retrieve this opportunity data in my C4C system by querying its id:

clipboard5
clipboard5

Of source this example might not make much sense from business perspective as in real world we tend to use other criteria like customer name to query Opportunity. Paste the following xml source code in request view to query on Opportunity 15360.

把下列的XML字符串复制到soapui面板里:

代码语言:javascript
复制
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global" xmlns:zzz="http://sap.com/xi/AP/CustomerExtension/BYD/ZZZZZ">
   <soapenv:Header/>
   <soapenv:Body>
      <glob:OpportunityByElementsQuery_sync_V1>
         <!--Optional:-->
         <OpportunitySelectionByElements>
            <!--Zero or more repetitions:-->
            <SelectionByIdentifier>
               <!--Optional:-->
               <InclusionExclusionCode>I</InclusionExclusionCode>
               <IntervalBoundaryTypeCode>1</IntervalBoundaryTypeCode>
               <!--Optional:-->
               <LowerBoundaryIdentifier>15360</LowerBoundaryIdentifier>
            </SelectionByIdentifier>
         </OpportunitySelectionByElements>
      </glob:OpportunityByElementsQuery_sync_V1>
   </soapenv:Body>
</soapenv:Envelope>

复制结束之后是这样的:这段字符串是我给soapui发起的web service的请求负载:

clipboard6
clipboard6

Execute this request, I meet with error message: 401 Unauthorized.

执行soapui请求,遇到了401 错误,原来我忘记维护用户名和密码了。

clipboard7
clipboard7

Then I manually maintained my business user and password in request property view:

此处维护消费这个web service的用户名和密码:

clipboard8
clipboard8

You might also need to maintain proxy setting for SoapUI according to your network landscape.

如果在企业内网的防火墙里使用soapui,还需要在此处设置代理服务器:

clipboard9
clipboard9

Once you have finished all such settings, execute request again and now you can see response as expected:

一切就绪之后,使用soapui能看到web service执行的响应内容了:

clipboard10
clipboard10
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年12月25日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档