Consume Webservice through Java

0

I have been given the following wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:sap-com:document:sap:rfc:functions" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" 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" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 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__ZFMGRC_SELECT_GRC">
      <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>
               <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
                  <wsp:Policy>
                     <sp:TransportToken>
                        <wsp:Policy>
                           <sp:HttpsToken>
                              <wsp:Policy>
                                 <sp:HttpBasicAuthentication />
                              </wsp:Policy>
                           </sp:HttpsToken>
                        </wsp:Policy>
                     </sp:TransportToken>
                     <sp:AlgorithmSuite>
                        <wsp:Policy>
                           <sp:Basic128Rsa15 />
                        </wsp:Policy>
                     </sp:AlgorithmSuite>
                     <sp:Layout>
                        <wsp:Policy>
                           <sp:Strict />
                        </wsp:Policy>
                     </sp:Layout>
                  </wsp:Policy>
               </sp:TransportBinding>
            </wsp:All>
         </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>
               <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
                  <wsp:Policy>
                     <sp:TransportToken>
                        <wsp:Policy>
                           <sp:HttpsToken>
                              <wsp:Policy>
                                 <sp:HttpBasicAuthentication />
                              </wsp:Policy>
                           </sp:HttpsToken>
                        </wsp:Policy>
                     </sp:TransportToken>
                     <sp:AlgorithmSuite>
                        <wsp:Policy>
                           <sp:Basic128Rsa15 />
                        </wsp:Policy>
                     </sp:AlgorithmSuite>
                     <sp:Layout>
                        <wsp:Policy>
                           <sp:Strict />
                        </wsp:Policy>
                     </sp:Layout>
                  </wsp:Policy>
               </sp:TransportBinding>
            </wsp:All>
         </wsp:All>
      </wsp:ExactlyOne>
   </wsp:Policy>
   <wsp:Policy wsu:Id="BN__ZFMGRC_SELECT_GRC_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>
               <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
                  <wsp:Policy>
                     <sp:TransportToken>
                        <wsp:Policy>
                           <sp:HttpsToken>
                              <wsp:Policy>
                                 <sp:HttpBasicAuthentication />
                              </wsp:Policy>
                           </sp:HttpsToken>
                        </wsp:Policy>
                     </sp:TransportToken>
                     <sp:AlgorithmSuite>
                        <wsp:Policy>
                           <sp:Basic128Rsa15 />
                        </wsp:Policy>
                     </sp:AlgorithmSuite>
                     <sp:Layout>
                        <wsp:Policy>
                           <sp:Strict />
                        </wsp:Policy>
                     </sp:Layout>
                  </wsp:Policy>
               </sp:TransportBinding>
            </wsp:All>
         </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>
               <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
                  <wsp:Policy>
                     <sp:TransportToken>
                        <wsp:Policy>
                           <sp:HttpsToken>
                              <wsp:Policy>
                                 <sp:HttpBasicAuthentication />
                              </wsp:Policy>
                           </sp:HttpsToken>
                        </wsp:Policy>
                     </sp:TransportToken>
                     <sp:AlgorithmSuite>
                        <wsp:Policy>
                           <sp:Basic128Rsa15 />
                        </wsp:Policy>
                     </sp:AlgorithmSuite>
                     <sp:Layout>
                        <wsp:Policy>
                           <sp:Strict />
                        </wsp:Policy>
                     </sp:Layout>
                  </wsp:Policy>
               </sp:TransportBinding>
            </wsp:All>
         </wsp:All>
      </wsp:ExactlyOne>
   </wsp:Policy>
   <wsp:Policy wsu:Id="IF__ZFMGRC_SELECT_GRC">
      <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>0050560000BE1ED58B918FC8EBD0F16B</sapcentraladmin:BusinessApplicationID>
            </sapcentraladmin:CentralAdministration>
         </wsp:All>
      </wsp:ExactlyOne>
   </wsp:Policy>
   <wsp:Policy wsu:Id="OP__ZFMGRC_SELECT_GRC">
      <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="char30">
            <xsd:restriction base="xsd:string">
               <xsd:maxLength value="30" />
            </xsd:restriction>
         </xsd:simpleType>
         <xsd:simpleType name="char72">
            <xsd:restriction base="xsd:string">
               <xsd:maxLength value="72" />
            </xsd:restriction>
         </xsd:simpleType>
         <xsd:simpleType name="string">
            <xsd:restriction base="xsd:string" />
         </xsd:simpleType>
         <xsd:complexType name="ZSTRING_TAB">
            <xsd:sequence>
               <xsd:element name="item" type="tns:string" minOccurs="0" maxOccurs="unbounded" />
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="ZDT_GET_SELECAO_ECC_FIELDS_TAB">
            <xsd:sequence>
               <xsd:element name="item" type="tns:char30" minOccurs="0" maxOccurs="unbounded" />
            </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="ZDT_GET_SELECAO_ECC_OPTION_TAB">
            <xsd:sequence>
               <xsd:element name="item" type="tns:char72" minOccurs="0" maxOccurs="unbounded" />
            </xsd:sequence>
         </xsd:complexType>
         <xsd:element name="ZFMGRC_SELECT_GRC">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element name="DADOS" type="tns:ZSTRING_TAB" />
                  <xsd:element name="DELIMITER" type="tns:string" />
                  <xsd:element name="FIELDS" type="tns:ZDT_GET_SELECAO_ECC_FIELDS_TAB" />
                  <xsd:element name="OPTIONS" type="tns:ZDT_GET_SELECAO_ECC_OPTION_TAB" />
                  <xsd:element name="TABLE" type="tns:string" />
               </xsd:sequence>
            </xsd:complexType>
         </xsd:element>
         <xsd:element name="ZFMGRC_SELECT_GRCResponse">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element name="DADOS" type="tns:ZSTRING_TAB" />
                  <xsd:element name="EXCEPTION" type="tns:string" />
                  <xsd:element name="FIELDS" type="tns:ZDT_GET_SELECAO_ECC_FIELDS_TAB" />
                  <xsd:element name="OPTIONS" type="tns:ZDT_GET_SELECAO_ECC_OPTION_TAB" />
                  <xsd:element name="REGISTROS_LIDOS" type="tns:string" />
               </xsd:sequence>
            </xsd:complexType>
         </xsd:element>
      </xsd:schema>
   </wsdl:types>
   <wsdl:message name="ZFMGRC_SELECT_GRC">
      <wsdl:part name="parameters" element="tns:ZFMGRC_SELECT_GRC" />
   </wsdl:message>
   <wsdl:message name="ZFMGRC_SELECT_GRCResponse">
      <wsdl:part name="parameter" element="tns:ZFMGRC_SELECT_GRCResponse" />
   </wsdl:message>
   <wsdl:portType name="ZFMGRC_SELECT_GRC">
      <wsdl:documentation>
         <sapdoc:sapdoc xmlns:sapdoc="urn:sap:esi:documentation">
            <sapdoc:docitem docURL="http://apacd08.melbras.com.br:8008/sap/bc/esdt/docu/sd_text?sap-client=100&amp;sd_name=ZFMGRC_SELECT_GRC" />
         </sapdoc:sapdoc>
      </wsdl:documentation>
      <wsp:Policy>
         <wsp:PolicyReference URI="#IF__ZFMGRC_SELECT_GRC" />
      </wsp:Policy>
      <wsdl:operation name="ZFMGRC_SELECT_GRC">
         <wsp:Policy>
            <wsp:PolicyReference URI="#OP__ZFMGRC_SELECT_GRC" />
         </wsp:Policy>
         <wsdl:input message="tns:ZFMGRC_SELECT_GRC" />
         <wsdl:output message="tns:ZFMGRC_SELECT_GRCResponse" />
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="ZFMGRC_SELECT_GRC" type="tns:ZFMGRC_SELECT_GRC">
      <wsp:Policy>
         <wsp:PolicyReference URI="#BN__ZFMGRC_SELECT_GRC" />
      </wsp:Policy>
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
      <wsdl:operation name="ZFMGRC_SELECT_GRC">
         <soap:operation soapAction="urn:sap-com:document:sap:rfc:functions:ZFMGRC_SELECT_GRC:ZFMGRC_SELECT_GRCRequest" 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="ZFMGRC_SELECT_GRC_soap12" type="tns:ZFMGRC_SELECT_GRC">
      <wsp:Policy>
         <wsp:PolicyReference URI="#BN__ZFMGRC_SELECT_GRC_soap12" />
      </wsp:Policy>
      <wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
      <wsdl:operation name="ZFMGRC_SELECT_GRC">
         <wsoap12:operation soapAction="urn:sap-com:document:sap:rfc:functions:ZFMGRC_SELECT_GRC:ZFMGRC_SELECT_GRCRequest" 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="ZFMGRC_SELECT_GRC">
      <wsdl:port name="ZFMGRC_SELECT_GRC" binding="tns:ZFMGRC_SELECT_GRC">
         <soap:address location="https://apacd08.melbras.com.br:44308/sap/bc/srt/rfc/sap/zfmgrc_select_grc/100/zfmgrc_select_grc/zfmgrc_select_grc" />
      </wsdl:port>
      <wsdl:port name="ZFMGRC_SELECT_GRC_soap12" binding="tns:ZFMGRC_SELECT_GRC_soap12">
         <wsoap12:address location="https://apacd08.melbras.com.br:44308/sap/bc/srt/rfc/sap/zfmgrc_select_grc/100/zfmgrc_select_grc/zfmgrc_select_grc" />
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

I placed this wsdl in Eclipse and generated the Client classes. And it generated the following classes: HoweverIamnotawareofconsumingthem.

Istartedthefollowingprogramming:

privateStringtesteConsumo()throwsException{finalStringCONFIG_FILE=Funcoes.getWFRootDir()+"upload/cadastros/config/sap_grc.properties";
    final String SELECAO_CONFIG_FILE    = Funcoes.getWFRootDir() + "upload/cadastros/config/sapSelecaoGrc.properties";
    Map<String, String> configSap       = Funcoes.getParametrosIntegracao(CONFIG_FILE);
    Map<String, String> configSelecao   = Funcoes.getParametrosIntegracao(SELECAO_CONFIG_FILE);
    ZFMGRC_SELECT_GRC_BindingStub stub = new ZFMGRC_SELECT_GRC_BindingStub();
    stub._setProperty(Stub.USERNAME_PROPERTY, Funcoes.nulo(configSap.get("userSap"), ""));
    stub._setProperty(Stub.PASSWORD_PROPERTY, Funcoes.nulo(configSap.get("passSap"), ""));
    stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, configSelecao.get("endPoint"));
//Aqui nao sei mais como continuar!
}

Here is an example of WS being consumed via SOAP UI:

    
asked by anonymous 17.08.2018 / 22:32

0 answers