Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

How to send a POST request from SAPUI5 to a soap wsdl webservice created in SAP

$
0
0

Hello SAPUI5 Experts,

 

I have a requirement in SAPui5 to consume and send a POST request to an WSDL service created on a RFC in SAP.

 

Details of service creation:

The webservice has been created on a RFC which again talks to a BAPI to create a Production Order.

Also created a binding for it with the soamanager transaction.

 

http://ides.XXXXXXXX.com:XXXX/sap/bc/srt/wsdl/sdef_ZPRODUCTION_ORDER1/wsdl11/ws_policy/document?sap-client=800

 

The service contains the following sections:

 

<xsd:schema xmlns:n0="urn:sap-com:document:sap:rfc:functions" attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style">

<xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/>

<xsd:complexType name="ZbapiPpOrder">

<xsd:sequence>

<xsd:element name="Material" type="n0:char18"/>

<xsd:element name="Plant" type="n0:char4"/>

<xsd:element name="OrderType" type="n0:char4"/>

<xsd:element name="BasicStartDate" type="n0:date"/>

<xsd:element name="BasicEndDate" type="n0:date"/>

<xsd:element name="Quantity" type="n0:quantum13.3"/>

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="Bapiret2">

<xsd:sequence>

<xsd:element name="Type" type="n0:char1"/>

<xsd:element name="Id" type="n0:char20"/>

<xsd:element name="Number" type="n0:numeric3"/>

<xsd:element name="Message" type="n0:char220"/>

<xsd:element name="LogNo" type="n0:char20"/>

<xsd:element name="LogMsgNo" type="n0:numeric6"/>

<xsd:element name="MessageV1" type="n0:char50"/>

<xsd:element name="MessageV2" type="n0:char50"/>

<xsd:element name="MessageV3" type="n0:char50"/>

<xsd:element name="MessageV4" type="n0:char50"/>

<xsd:element name="Parameter" type="n0:char32"/>

<xsd:element name="Row" type="xsd:int"/>

<xsd:element name="Field" type="n0:char30"/>

<xsd:element name="System" type="n0:char10"/>

</xsd:sequence>

</xsd:complexType>

<xsd:element name="ZproductionOrder">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="Orderdata" type="tns:ZbapiPpOrder"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="ZproductionOrderResponse">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="OrderNumber" type="n0:char12"/>

<xsd:element name="OrderType" type="n0:char4"/>

<xsd:element name="Return" type="tns:Bapiret2"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>

</wsdl:types>

<wsdl:message name="ZproductionOrder">

<wsdl:part name="parameters" element="tns:ZproductionOrder"/>

</wsdl:message>

<wsdl:message name="ZproductionOrderResponse">

<wsdl:part name="parameter" element="tns:ZproductionOrderResponse"/>

</wsdl:message>

<wsdl:portType name="ZPRODUCTION_ORDER1">

<wsp:Policy>

<wsp:PolicyReference URI="#IF_IF_ZPRODUCTION_ORDER1"/>

</wsp:Policy>

<wsdl:operation name="ZproductionOrder">

<wsp:Policy>

<wsp:PolicyReference URI="#OP_IF_OP_ZproductionOrder"/>

</wsp:Policy>

<wsdl:input message="tns:ZproductionOrder"/>

<wsdl:output message="tns:ZproductionOrderResponse"/>

</wsdl:operation>

</wsdl:portType>

</wsdl:definitions>

 

 

In SAPUI5 i am trying to post the request to the above service using an ajax call as follows:

 

var request = '<?xml version="1.0" encoding="UTF-8" ?>' +

  '<SOAP-ENV:Envelope' +

  'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' +

  'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +

  'xmlns:xs="http://www.w3.org/2001/XMLSchema"> ' +

     '<SOAP-ENV:Header> ' +

         '<sapsess:Session xmlns:sapsess="http://www.sap.com/webas/630/soap/features/session/">' +

            ' <enableSession>true</enableSession> ' +

         '</sapsess:Session> ' +

     '</SOAP-ENV:Header> ' +

     '<SOAP-ENV:Body> ' +    

  '<n0:ZproductionOrder xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">' +

  '<Orderdata>' +

   '<Material>000000000000003709</Material>' +

   '<Plant>SA01</Plant>' +

   '<OrderType>PP01</OrderType>' +

   '<BasicStartDate>2016-05-20</BasicStartDate>' +

   '<BasicEndDate>2016-05-20</BasicEndDate>' +

   '<Quantity>1</Quantity>' +

  '</Orderdata>' +

  '</n0:ZproductionOrder>' +

     '</SOAP-ENV:Body>' +

  '</SOAP-ENV:Envelope>'

 

$.ajax({

url : "proxy/http/XXXXXXX:XXXX/sap/bc/srt/wsdl/sdef_ZPRODUCTION_ORDER1/wsdl11/ws_policy/document?sap-client=800",

type: "POST",

data : request,

dataType: "xml",

async: false,

contentType : "text/xml",

success: function(data, textStatus, jqXHR){

      alert("ok" +textStatus);

      console.log(data);    

      },

    error: function(){alert("error");}

  });

 

Result: The function call is successful but i am getting a blank response as follows and also no production order is generated in SAP.

 

<xsd:element name="ZproductionOrder">

<xsd:complexType><xsd:sequence>

<xsd:element name="Orderdata" type="tns:ZbapiPpOrder"/>

</xsd:sequence></xsd:complexType></xsd:element>

<xsd:element name="ZproductionOrderResponse">

<xsd:complexType><xsd:sequence>

<xsd:element name="OrderNumber" type="n0:char12"/>

<xsd:element name="OrderType" type="n0:char4"/>

<xsd:element name="Return" type="tns:Bapiret2"/>

</xsd:sequence></xsd:complexType></xsd:element>

</xsd:schema></wsdl:types>

<wsdl:message name="ZproductionOrder"><wsdl:part name="parameters" element="tns:ZproductionOrder"/></wsdl:message>

<wsdl:message name="ZproductionOrderResponse"><wsdl:part name="parameter" element="tns:ZproductionOrderResponse"/></wsdl:message><wsdl:portType name="ZPRODUCTION_ORDER1"><wsp:Policy><wsp:PolicyReference URI="#IF_IF_ZPRODUCTION_ORDER1"/></wsp:Policy><wsdl:operation name="ZproductionOrder"><wsp:Policy><wsp:PolicyReference URI="#OP_IF_OP_ZproductionOrder"/></wsp:Policy><wsdl:input message="tns:ZproductionOrder"/><wsdl:output message="tns:ZproductionOrderResponse"/></wsdl:operation></wsdl:portType></wsdl:definitions>

 

Please provide your inputs on the above approach and specify how to proceed with sending a POST request to a wsdl soap service created in sap from sapui5.

Please let me know if some more information is required regarding the question.

 

Thanks and Regards,

Vinayak P


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>