Search code examples
c#xmlwcfsoapsap-basis

SOAP endpoint to be called from SAP


I have been tasked with writing a web-service that will be used as an integration point between an ASP.NET MVC application and corporate SAP. Basically, I just have to write a SOAP web-service (Wcf SOAP) with an endpoint that SAP will call and transmit a bunch of data that I will then have to store in a SQL Server database.

I've never written a web-service before and am a but unsure on how the process will ultimately work. I generated an XML schema from the EF classes in the MVC application which I plan to provision SAP with for the data they are to send to the web-service. My solution designer suggested that I mimic the message structure that he uses in one of his REST web-services. This structure is as follows for the in-comming request:

public class DtoRequest<T> : IDtoRequest where T : class
{
    public InteractionContext Context { get; set; }
    public T Request { get; set; }
}

The InteractionContext is to hold various properties such details of the calling application and a license key for authentication. The Request will contain the payload.

namespace RfqService.Messages
{
    public class SendRfqRequest : DtoRequest<RequestDataDto>
    {
    }

    public class SendRfqResponse : DtoResponse<DtoVoidResponse>
    {
    }
}

The RequestDataDto looks as follows:

namespace RfqService.DataTransferObjects
{
    [DataContract]
    public class RequestDataDto
    {
        [DataMember]
        public int RequestId { get; set; }

        [DataMember]
        public DateTime CreatedDate { get; set; }

        [DataMember]
        public DateTime DateProcessed { get; set; }

        [DataMember]
        public string Status { get; set; }

        [DataMember]
        public string XmlData { get; set; }
    }
}

What I'm planning is for the XmlData in the RequestDataDto to contain the xml data sent from SAP that I can then deserialize into the EF classes and persist to the database.

SAP can then call an endpoint in my .asmx file:

[WebMethod]
public SendRfqResponse SendRfq(SendRfqRequest request)
{ ... }

Problem I'm facing is when inspecting the implementation of the the REST service of the solution designer. He calls the REST endpoint from a Webforms application. I can see how he constructs the message object in C# and send it to the web-service. I have no idea how this will work when its coming from a different platform like SAP. I've been trying to read up on SOAP in general and have come across the following extract here:

The primary difference between ORPC and the RPC protocols that preceded them was that ORPC codified the mapping of a communication endpoint to a language-level object.

Is the data sent from SAP automatically converted to my Request object? Does the data come in XML and I have to deserialize it into my object that in turn contains xml data in the payload? Are the parameters in the InteractionContext come from what's in the SOAP object's header? Do I have to serialize my response into xml before returning it to SAP?


Solution

  • Example If you are doing a REST web service call

    If you really are doing a SOAP call.

    Then load create a new client service using the wsdl from IIS where the service is hosted. This will create a PROXY in ABAP. You just call that proxy.

    The data sent is transformed in XML as per the WSDL definition for you. Equally on the IIS end the Service should populate the your Data Contract type for you automatically.

    You should not have to worry about XML anywhere if done properly and you are using SOAP. ABAP->IIS

    if its aysnch call you will need to set up reliable messaging on the SAP side. That will keep you basis guy busy