C# 将SOAPSonar转换为C时发生XML验证错误#

C# 将SOAPSonar转换为C时发生XML验证错误#,c#,.net,xml,soap,wsdl,C#,.net,Xml,Soap,Wsdl,我可以在SOAPSonar中毫无问题地运行以下SOAP请求(通过WSDL生成),并返回数据: <?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/200

我可以在SOAPSonar中毫无问题地运行以下SOAP请求(通过WSDL生成),并返回数据:

<?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>

1200
Y
收入账户
Y
A.
A.
Y
N
Y
Y
Y
N
Y
N
我尝试在C#中实现请求,如下所示(基于):

publicstaticstringcallwebservice(stringurl,int-RefNum)
{
XmlDocument信封=CreateEnvelope(RefNum);
HttpWebRequest请求=CreateRequest(URL);
插入信封(请求、信封);
IAsyncResult AsyncResult=Request.BeginGetResponse(null,null);
AsyncResult.AsyncWaitHandle.WaitOne();
字符串结果;
使用(WebResponse-Response=Request.EndGetResponse(AsyncResult))
{
使用(StreamReader=newstreamreader(Response.GetResponseStream())Result=Reader.ReadToEnd();
}
返回结果;
}
私有静态XmlDocument CreateEnvelope(int RefNum)
{
XmlDocument信封=新的XmlDocument();
Envelope.LoadXml(
String.Format(@)
{0}
Y
收入账户
Y
A.
A.
Y
Y
Y
Y
Y
N
Y
N
,RefNum.ToString())
);
返回信封;
}
私有静态HttpWebRequest CreateRequest(字符串URL)
{
HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(URL);
//添加(@“SOAP:Action”);
Request.ContentType=“text/xml;charset=\”utf-8\”;
Request.Accept=“text/xml”;
Request.Method=“POST”;
返回请求;
}
私有静态void InsertEnvelope(HttpWebRequest请求,XmlDocument信封)
{
使用(Stream=Request.GetRequestStream())信封.Save(Stream);
}
但我收到以下错误的回复:

  • ORA-31043:架构中未全局定义元素“信封” 'GET_PERSON_DETAILS.xsd'
  • 提供的XML验证失败。联系支持部门

    • 这里的问题是SOAPAction头。 我把它改成:

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

      Request.Headers.Add("SOAPAction", (URL + "gateway"));
      
      Request.Headers.Add("SOAPAction", (URL + "gateway"));