SAP ABAP WebService 使用手册及,外部调用不用传递账号密码的设置方式!!!一文给你说清!!!

第一步:SE37 创建一个远程函数(Remote Function Module)

注意该函数需要将Remote Enable开启

第二步:创建WebService

首先:SE37 打开需要关联的函数在菜单 Utilities->More Utilities->Create Web Service->From the Function Module 执行

然后:根据引导一步步创建即可

最后:执行SOAMANAGER

选择Web Service Configuration 进行相关配置即可

配置好后

点击上图小车左边的那个图标即可查看对外URL

第三步:初次使用时激活和关闭的相关服务

事务码SICF然后执行进入定义服务页面

需激活

/default_host/sap/bc/soap

– /default_host/sap/bc/srt

– /default_host/sap/bc/srt/rfc/sap

– /default_host/sap/bc/srt/rfc/wsdl

– /default_host/sap/bc/webdynpro/sap

– /default_host/sap/bc/webdynpro/sap/appl_soap_management.

需关闭

若是执行SOAMANAGER事务码提示500 则可关闭一下服务试一下

– /default_host/sap/public/myssocntl

第四步:访问URL

响应如下

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:rfc:functions" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" targetNamespace="urn:sap-com:document:sap:rfc:functions">
<wsdl:documentation>
<sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/>
</wsdl:documentation>
<wsp:UsingPolicy wsdl:required="true"/>
<wsp:Policy wsu:Id="BN__ZABAPWEBSERVICE">
<wsp:ExactlyOne>
<wsp:All>
<sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
<saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
<wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
</wsp:All>
<wsp:All>
<sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
<saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/>
<wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="BN__ZABAPWEBSERVICE_soap12">
<wsp:ExactlyOne>
<wsp:All>
<sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
<saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
<wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
</wsp:All>
<wsp:All>
<sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
<saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" uri="http://xml.sap.com/2006/11/esi/esp/binxml" wsp:Optional="true"/>
<wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="IF__ZWEB">
<wsp:ExactlyOne>
<wsp:All>
<sapsession:Session xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/">
<sapsession:enableSession>false</sapsession:enableSession>
</sapsession:Session>
<sapcentraladmin:CentralAdministration xmlns:sapcentraladmin="http://www.sap.com/webas/700/soap/features/CentralAdministration/" wsp:Optional="true">
<sapcentraladmin:BusinessApplicationID>A3238217E7E71EEDAFDCEF9309F89194</sapcentraladmin:BusinessApplicationID>
</sapcentraladmin:CentralAdministration>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="OP__ZABAP_WEBSERVICE_1">
<wsp:ExactlyOne>
<wsp:All>
<saptrhnw05:required xmlns:saptrhnw05="http://www.sap.com/NW05/soap/features/transaction/">no</saptrhnw05:required>
<sapcomhnd:enableCommit xmlns:sapcomhnd="http://www.sap.com/NW05/soap/features/commit/">false</sapcomhnd:enableCommit>
<sapblock:enableBlocking xmlns:sapblock="http://www.sap.com/NW05/soap/features/blocking/">true</sapblock:enableBlocking>
<saprmnw05:enableWSRM xmlns:saprmnw05="http://www.sap.com/NW05/soap/features/wsrm/">false</saprmnw05:enableWSRM>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types>
<xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
<xsd:simpleType name="char10">
...
</xsd:simpleType>
<xsd:element name="ZABAP_WEBSERVICE_1">
<xsd:complexType>
<xsd:sequence/>
</xsd:complexType>
</xsd:element>
<xsd:element name="ZABAP_WEBSERVICE_1Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ZHELLO" type="tns:char10"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ZABAP_WEBSERVICE_1">
<wsdl:part name="parameters" element="tns:ZABAP_WEBSERVICE_1"/>
</wsdl:message>
<wsdl:message name="ZABAP_WEBSERVICE_1Response">
<wsdl:part name="parameter" element="tns:ZABAP_WEBSERVICE_1Response"/>
</wsdl:message>
<wsdl:portType name="ZWEB">
<wsp:Policy>
<wsp:PolicyReference URI="#IF__ZWEB"/>
</wsp:Policy>
<wsdl:operation name="ZABAP_WEBSERVICE_1">
<wsp:Policy>
<wsp:PolicyReference URI="#OP__ZABAP_WEBSERVICE_1"/>
</wsp:Policy>
<wsdl:input message="tns:ZABAP_WEBSERVICE_1"/>
<wsdl:output message="tns:ZABAP_WEBSERVICE_1Response"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ZABAPWEBSERVICE" type="tns:ZWEB">
<wsp:Policy>
<wsp:PolicyReference URI="#BN__ZABAPWEBSERVICE"/>
</wsp:Policy>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="ZABAP_WEBSERVICE_1">
<soap:operation soapAction="urn:sap-com:document:sap:rfc:functions:ZWEB:ZABAP_WEBSERVICE_1Request" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ZABAPWEBSERVICE_soap12" type="tns:ZWEB">
<wsp:Policy>
<wsp:PolicyReference URI="#BN__ZABAPWEBSERVICE_soap12"/>
</wsp:Policy>
<wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="ZABAP_WEBSERVICE_1">
<wsoap12:operation soapAction="urn:sap-com:document:sap:rfc:functions:ZWEB:ZABAP_WEBSERVICE_1Request" style="document"/>
<wsdl:input>
<wsoap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsoap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ZABAPWEBSERVICE">
<wsdl:port name="ZABAPWEBSERVICE" binding="tns:ZABAPWEBSERVICE">
<soap:address location="http://vhcalnplci:8000/sap/bc/srt/rfc/sap/zweb/001/zabapwebservice/zabapwebservice"/>
</wsdl:port>
<wsdl:port name="ZABAPWEBSERVICE_soap12" binding="tns:ZABAPWEBSERVICE_soap12">
<wsoap12:address location="http://vhcalnplci:8000/sap/bc/srt/rfc/sap/zweb/001/zabapwebservice/zabapwebservice"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

可能遇到的问题及解决方案

HTTP 500,HTTP403

检查第三步中的服务是否已开启或者关闭

解决需要输入登录账号和密码

在SAP GUI 执行事务码 找到对应的服务

例如这里是ZWEB

把ZWEB 上层的 SAP服务的Login Data设置默认用户

这样就无需输入账号密码也能访问了

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ABAP是一种编程语言,用于SAP系统的开发,可以通过WebService(Web服务)与外部系统进行交互。 在ABAP调用外部WebService,需要通过调用SOAP(简单对象访问协议)或REST(表述性状态传递)协议来与WebService进行通信。 首先,需要在ABAP中创建一个代表外部WebService的客户端代理。可以使用SAP提供的工具例如SOAMANAGER或SE80等来创建代理。这些工具可以根据WebService的WSDL文件自动生成代理代码。WSDL(Web服务描述语言)是一种描述WebService接口的XML文件。 在创建代理之后,可以使用ABAP代码调用外部WebService。根据WebService的具体接口定义,调用不同的方法,传递相应的参数。ABAP提供了一些函数模块或类来进行WebService调用,例如CALL FUNCTION或CREATE OBJECT等。 在调用WebService方法时,将传递参数并获取返回值。ABAP代码可以处理WebService返回的结果,根据需要进行后续的逻辑处理。 在调用过程中,还需要设置通信所需的协议和认证信息。ABAP提供了相关函数模块或类来设置和处理这些通信和认证信息,例如SET HANDLER或SET PROPERTY等。 在调用WebService之前,还需要确保网络连接的可用性,以及外部WebService的可访问性。可以通过网络配置或者与网络管理员进行沟通来解决相关问题。 总之,ABAP调用外部WebService的过程可以归纳为以下几个步骤:创建WebService客户端代理、调用WebService方法、处理返回结果、设置通信和认证信息、确保网络连接的可用性。这样,就可以在ABAP程序中方便地与外部系统进行数据交互。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值