未声明SOAP信封元素

问题描述 投票:0回答:2

我正在发送给外部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服务本身的服务器端问题?还是我的代码中出了什么问题?

php web-services soap wsdl soapui
2个回答
0
投票

回答我自己的问题。

我直接与政府IT协助联系,并让他们给我发送了代码示例。他们使用了一种非常不寻常且经过修改的<soap包装器形式,迫使我使用SimpleXMLElement手动生成XML,并使用具有SoapVar类型的包装的XSD_ANYXML将其提交到Web服务。


0
投票

您对此有任何解决方案...

© www.soinside.com 2019 - 2024. All rights reserved.