0

I can run the following SOAP request (generated via a WSDL) in SOAPSonar without a problem and I get data back:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ng1="http://www.sx3.com/GET_PERSON_DETAILS">
  <soap:Body>
    <ng1:ParDetailsRequest>
      <ng1:ParRefno>1200</ng1:ParRefno>
      <ng1:FormerNameChkInd>Y</ng1:FormerNameChkInd>
      <ng1:RacPay>REVENUE ACCOUNT</ng1:RacPay>
      <ng1:CurrentParInd>Y</ng1:CurrentParInd>
      <ng1:CurrentAppInd>A</ng1:CurrentAppInd>
      <ng1:CurrentTcyInd>A</ng1:CurrentTcyInd>
      <ng1:RtnContactAddrInd>Y</ng1:RtnContactAddrInd>
      <ng1:RtnContactDetailsInd>N</ng1:RtnContactDetailsInd>
      <ng1:RtnAusInd>Y</ng1:RtnAusInd>
      <ng1:RtnAppInd>Y</ng1:RtnAppInd>
      <ng1:RtnTcyInd>Y</ng1:RtnTcyInd>
      <ng1:RtnOtherFieldsInd>N</ng1:RtnOtherFieldsInd>
      <ng1:RtnFmrNameHistInd>Y</ng1:RtnFmrNameHistInd>
      <ng1:RtnNotepadsInd>N</ng1:RtnNotepadsInd>
    </ng1:ParDetailsRequest>
  </soap:Body>
</soap:Envelope>

I attempted to implement the request in C# as follows (based on this answer):

public static String CallWebService(String URL, int RefNum)
{

    XmlDocument Envelope = CreateEnvelope(RefNum);
    HttpWebRequest Request = CreateRequest(URL);
    InsertEnvelope(Request, Envelope);

    IAsyncResult AsyncResult = Request.BeginGetResponse(null, null);
    AsyncResult.AsyncWaitHandle.WaitOne();

    String Result;

    using (WebResponse Response = Request.EndGetResponse(AsyncResult))
    {
        using (StreamReader Reader = new StreamReader(Response.GetResponseStream())) Result = Reader.ReadToEnd();
    }

    return Result;

}

private static XmlDocument CreateEnvelope(int RefNum)
{

    XmlDocument Envelope = new XmlDocument();

    Envelope.LoadXml(
        String.Format(@"
            <soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:ng1=""http://www.sx3.com/GET_PERSON_DETAILS"">
                <soap:Body>
                    <ng1:ParDetailsRequest>
                        <ng1:ParRefno>{0}</ng1:ParRefno>
                        <ng1:FormerNameChkInd>Y</ng1:FormerNameChkInd>
                        <ng1:RacPay>REVENUE ACCOUNT</ng1:RacPay>
                        <ng1:CurrentParInd>Y</ng1:CurrentParInd>
                        <ng1:CurrentAppInd>A</ng1:CurrentAppInd>
                        <ng1:CurrentTcyInd>A</ng1:CurrentTcyInd>
                        <ng1:RtnContactAddrInd>Y</ng1:RtnContactAddrInd>
                        <ng1:RtnContactDetailsInd>Y</ng1:RtnContactDetailsInd>
                        <ng1:RtnAusInd>Y</ng1:RtnAusInd>
                        <ng1:RtnAppInd>Y</ng1:RtnAppInd>
                        <ng1:RtnTcyInd>Y</ng1:RtnTcyInd>
                        <ng1:RtnOtherFieldsInd>N</ng1:RtnOtherFieldsInd>
                        <ng1:RtnFmrNameHistInd>Y</ng1:RtnFmrNameHistInd>
                        <ng1:RtnNotepadsInd>N</ng1:RtnNotepadsInd>
                    </ng1:ParDetailsRequest>
                </soap:Body>
            </soap:Envelope>
        ", RefNum.ToString())
    );

    return Envelope;

}

private static HttpWebRequest CreateRequest(String URL)
{

    HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(URL);
    //Request.Headers.Add(@"SOAP:Action");
    Request.ContentType = "text/xml;charset=\"utf-8\"";
    Request.Accept = "text/xml";
    Request.Method = "POST";
    return Request;

}

private static void InsertEnvelope(HttpWebRequest Request, XmlDocument Envelope)
{
    using (Stream Stream = Request.GetRequestStream()) Envelope.Save(Stream);
}

But I receive the following errors in response:

  • ORA-31043: Element 'Envelope' not globally defined in schema 'GET_PERSON_DETAILS.xsd'
  • The supplied XML has failed validation. Contact Support.
Conor McCauley
  • 103
  • 1
  • 1
  • 11

1 Answers1

0

The problem here was with the SOAPAction header. I changed it from this:

Request.Headers.Add(@"SOAP:Action");

to this:

Request.Headers.Add("SOAPAction", (URL + "gateway"));
Conor McCauley
  • 103
  • 1
  • 1
  • 11