martes, 21 de abril de 2015

Consumo de web services con xsd:dateTime (UTC) en SAP.

Para los web services que tienen tipo de datos xsd:dateTime, sap los transforma en el tipo sap XSDDATETIME_Z (Evento XSD (UTC): aaaa-mm-ddThh:ssZ [ext.]). Este tipo de dato guarda internamente la fecha, la hora y el huso horario.

Para poder pasar de UTC a fecha, hora y huso y viceversa podemos servirnos de guía de este código que he extraido de la clase de SAP cl_appointment. Prueba con este código.

Programa de ejemplo.

  DATAl_tst TYPE xsddatetime_z"LIKE scappt-tst_from,
        l_zone TYPE tznzone,      "LIKE scappt-zone_from,
        l_date TYPE datum,        "LIKE scappt-date_from,
        l_time TYPE sytime.       "LIKE scappt-time_from.

  CLEARl_tstl_zonel_datel_time.
*
  GET TIME STAMP FIELD l_tst.
  l_zone 'CET'."No es necesario si nos viene ya dentro del l_tst y nos lo resolvería el convert time. 
*
  WRITE'UTC->fecha, hora, huso'.
*
  CONVERT TIME STAMP l_tst
           TIME ZONE l_zone
           INTO DATE l_date
                TIME l_time.
*
  WRITE'TIME STAMP 'l_tst.
*
  WRITE'ZONE 'l_zone.
  WRITE'DATE 'l_date.
  WRITE'TIME 'l_time.
*
  WRITE/.
  WRITE'fecha, hora, huso->UTC'.
*
  CLEARl_tstl_zonel_datel_time.
*
  l_date sy-datum.
  l_time sy-uzeit.
  l_zone SY-ZONLO.
*
  CONVERT DATE l_date
  TIME l_time
  INTO TIME STAMP l_tst
  TIME ZONE l_zone.
*
  WRITE'ZONE 'l_zone.
  WRITE'DATE 'l_date.
  WRITE'TIME 'l_time.
*
  WRITE'TIME STAMP 'l_tst.
*

domingo, 19 de abril de 2015

Excepción de clase CX_AI_SOAP_FAULT (SoapFaultCode:4 ) al invocar un WebService.

Para este errores al intentar implementar un Web Services que había creado en .Net:

SoapFaultCode:4  System.Web.Services.Protocols.SoapException: Server did not
recognize the value of HTTP Header SOAPAction: .##   at
System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()##   at
System.Web.Services.Protocols.SoapServerProtocol.Initialize()##   at
System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&

abortProcessing)


    Excepción de clase CX_AI_SOAP_FAULT

Solución.

En el soamanager he ido al endpoint que había creado. Luego en pestaña "Operation Specific" hay que mirar que todas las operaciones tengan el SOAP Action informado. 

viernes, 17 de abril de 2015

Excepción de clase CX_AI_SOAP_FAULT (SoapFaultCode:3 ) al invocar un WebService.

Para estos 2 errores al intentar implementar un par Web Services que había creado en .Net:

Error 1.

SoapFaultCode:3  The header 'Action' from the namespace
http://schemas.xmlsoap.org/ws/2004/08/addressing' was not understood by the
ecipient of this message, causing the message to not be processed.  This
rror typically indicates that the sender of this message has enabled a
ommunication protocol that the receiver cannot process.  Please ensure that
he configuration of the client's binding is consistent with the service's
inding.

   Excepción de clase CX_AI_SOAP_FAULT

Error 2.

SoapFaultCode:3  System.Web.Services.Protocols.SoapHeaderException: SOAP
header Action was not understood.##   at
System.Web.Services.Protocols.SoapHeaderHandling.
SetHeaderMembers(SoapHeaderCollection headers, Object target,
SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client)##
at System.Web.Services.Protocols.SoapServerProtocol.CreateServerInstance()##
at System.Web.Services.Protocols.WebServiceHandler.Invoke()##   at
System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

    Excepción de clase CX_AI_SOAP_FAULT

Solución.

En el soamanager he ido al endpoint que había creado. Luego en pestaña Messaging y en Message ID Protocol lo he cambiado a "SAP Message ID".