未声明SOAP信封元素

时间:2015-08-10 01:27:34

标签: php web-services soap wsdl soapui

我遇到的问题是我发送到外部ASP Web服务的SOAP请求。我已经使用了SoapUI和PHP的SoapClient类,并且两次出现同样的问题 - 这个错误告诉我The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.

我对'GetStudentEntitlement'的请求

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/" xmlns:heim="http://dest.gov.au/Heims/">
   <soap:Header/>
   <soap:Body><adm:GetStudentEntitlement>
         <heim:entitlementRequest>
            <heim:RequestControlTable>
               <heim:RequestId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RequestId>
               <heim:ClientOrganisationCode>7591</heim:ClientOrganisationCode>
               <heim:RequestLocalDateTime>2015-08-10T00:00:00</heim:RequestLocalDateTime>
            </heim:RequestControlTable>
            <heim:GetEntitlementIn>
               <heim:RecordId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RecordId>
               <heim:Chessn>1344</heim:Chessn>
               <heim:FamilyName>Bassett</heim:FamilyName>
               <heim:BirthDate>1988-05-21</heim:BirthDate>
            </heim:GetEntitlementIn>
         </heim:entitlementRequest>
      </adm:GetStudentEntitlement>
   </soap:Body>
</soap:Envelope>

回复:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <soap:Code>
            <soap:Value>soap:Sender</soap:Value>
         </soap:Code>
         <soap:Reason>
            <soap:Text xml:lang="en">Heims.WebServices.Extensions.Exceptions.XmlSchemaValidationException: Schema validation errors
   at Heims.WebServices.Extensions.SoapFilterExtension.ValidateXmlMessage(SoapMessage message, WebMethodSettings methodSettings) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 408
   at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessageBeforeDeserialise(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 200
   at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessage(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 173
   at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</soap:Text>
         </soap:Reason>
         <detail>
            <ValidationError>
               <RecordId/>
               <Element>Envelope</Element>
               <Line>1</Line>
               <Column>2</Column>
               <Description>The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.</Description>
            </ValidationError>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

我尝试在/声明中添加和删除尾随:soap,以及尝试此Web服务提供的1.11.2 SOAP版本。

'Ping' 的端点请求正常工作

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/">
   <soap:Header/>
   <soap:Body>
      <adm:Ping/>
   </soap:Body>
</soap:Envelope>

结果按预期返回:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <PingResponse xmlns="http://dest.gov.au/Heims/Admin/">
         <PingResult>Heims web services pinged. DateTime = 2015-08-10 11:11:00:05</PingResult>
      </PingResponse>
   </soap:Body>
</soap:Envelope>

所以为什么一个请求(ping)的代码能够完美地工作,而另一个请求(GetStudentEntitlement)会失败吗?两者都有soap:Envelope声明,但Ping请求正常。

我也尝试在xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"元素中使用soap:Envelope,但错误仍然存​​在。

这可能是Web服务本身的服务器端问题吗?或者我的代码中出现了什么问题?

2 个答案:

答案 0 :(得分:0)

回答我自己的问题。

我直接联系政府IT援助,并让他们发给我一个代码示例。他们使用了一种非常不寻常且经过修改的<soap包装器形式,迫使我使用SimpleXMLElement手动生成XML,并使用包含SoapVar XSD_ANYXML的{​​{1}}提交给Web服务} type。

答案 1 :(得分:0)

您对此有任何解决方案吗?

今天我在将UTL_DBWS实用程序(oracle plsql)转换为APEX实用程序以调用HEIMS Web服务时遇到了相同的问题。

Ping有效,但是GetStudentEntitlements和AllocateStudentChessn都因相同的信封错误而失败。

问候 RC