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

本文就以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:

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

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

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

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文件。

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

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面板里:

<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的请求负载:

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

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

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

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

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

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

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

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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券