PHP와 SOAP 웹 서비스의 ComplexType 액세스



web-services (1)

나는 webservice에 전화를하고 싶다. 그리고 webservice에는 complextype 요소가 포함되어 있습니다. ASP.NET과 soapUI로 좋은 결과를 얻고 있습니다. 하지만 PHP에 오류가 발생했습니다. 나는 알아낼 수 없었다.

그래서 제발 도와 주실 수 있습니까?

감사.

내가 전화하고 싶은 기능 :

<xs:element name="GetHotelSearch">
  <xs:complexType>
     <xs:sequence>
        <xs:element minOccurs="0" name="searchClass" nillable="true" type="q13:HotelSearch" xmlns:q13="http://schemas.datacontract.org/2004/07/Model"/>
        <xs:element minOccurs="0" name="recorCount" type="xs:int"/>
        <xs:element minOccurs="0" name="sortType" type="q14:SortType" xmlns:q14="http://schemas.datacontract.org/2004/07/Model"/>
        <xs:element minOccurs="0" name="sortFields" nillable="true" type="q15:ArrayOfSortField" xmlns:q15="http://schemas.datacontract.org/2004/07/Model"/>
     </xs:sequence>
  </xs:complexType>
</xs:element>
<xs:element name="GetHotelSearchResponse">
  <xs:complexType>
     <xs:sequence>
        <xs:element minOccurs="0" name="GetHotelSearchResult" nillable="true" type="q16:ArrayOfHotelSummary" xmlns:q16="http://schemas.datacontract.org/2004/07/Model"/>
        <xs:element minOccurs="0" name="recorCount" type="xs:int"/>
     </xs:sequence>
  </xs:complexType>
</xs:element>

복합 유형 :

   <xs:complexType name="HotelSearch">
      <xs:sequence>
         <xs:element minOccurs="0" name="BRANCHID" type="xs:int"/>
         <xs:element minOccurs="0" name="UNIQUECODE" nillable="true" type="xs:string"/>
      </xs:sequence>
   </xs:complexType>

   <xs:simpleType name="SortType">
      <xs:restriction base="xs:string">
         <xs:enumeration value="Ascending">
            <xs:annotation>
               <xs:appinfo>
                  <EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1</EnumerationValue>
               </xs:appinfo>
            </xs:annotation>
         </xs:enumeration>
         <xs:enumeration value="Descending">
            <xs:annotation>
               <xs:appinfo>
                  <EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">2</EnumerationValue>
               </xs:appinfo>
            </xs:annotation>
         </xs:enumeration>
      </xs:restriction>
   </xs:simpleType>

   <xs:element name="SortType" nillable="true" type="tns:SortType"/>
   <xs:complexType name="ArrayOfSortField">
      <xs:sequence>
         <xs:element minOccurs="0" maxOccurs="unbounded" name="SortField" type="tns:SortField"/>
      </xs:sequence>
   </xs:complexType>

   <xs:element name="ArrayOfSortField" nillable="true" type="tns:ArrayOfSortField"/>
   <xs:simpleType name="SortField">
      <xs:restriction base="xs:string">
         <xs:enumeration value="PENSIONTYPENAME">
            <xs:annotation>
               <xs:appinfo>
                  <EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1</EnumerationValue>
               </xs:appinfo>
            </xs:annotation>
         </xs:enumeration>
         <xs:enumeration value="HOTELNAME">
            <xs:annotation>
               <xs:appinfo>
                  <EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">2</EnumerationValue>
               </xs:appinfo>
            </xs:annotation>
         </xs:enumeration>
      </xs:restriction>
   </xs:simpleType>
   <xs:element name="SortField" nillable="true" type="tns:SortField"/>

.NET 코드 (작동 중) :

int _recordCount = 10;
List<HotelSummary> hotels = hc.GetHotelSearch(new HotelSearch()
{
    BRANCHID = 000,
    UNIQUECODE = "YIO"
}, ref _recordCount, SortType.Ascending, new SortField[] { SortField.HOTELNAME }).ToList();

XML (soapUI와 작동합니다) :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:mod="http://schemas.datacontract.org/2004/07/Model">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetHotelSearch>
         <tem:searchClass>
             <mod:BRANCHID>000</mod:BRANCHID>
             <mod:UNIQUECODE>YIO</mod:UNIQUECODE>
         </tem:searchClass>
         <tem:recorCount>10</tem:recorCount>
         <tem:sortType>Ascending</tem:sortType>
         <tem:sortFields>
             <mod:SortField>HOTELNAME</mod:SortField>
         </tem:sortFields>
      </tem:GetHotelSearch>
   </soapenv:Body>
</soapenv:Envelope>

그리고 PHP 코드 (그것은 작동하지 않습니다) :

ini_set("soap.wsdl_cache_enabled", "0");

$url='http://localhost/Service/Service.svc?wsdl';

$client = new SoapClient($url);

$HotelSearch= array('BRANCHID' => 000,'UNIQUECODE' => 'YIO');
$SortField= array('SortField' => 'HOTELNAME');

$result = $client->GetHotelSearch($HotelSearch, 10, 'Ascending', $SortField);

$array = $result->GetHotelSearchResult->HotelSummary;

이 오류가 발생합니다.

Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault] End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 155. in D:\[.Projeler]\musteri\webservis\test.php:98 Stack trace: #0 D:\[.Projeler]\musteri\webservis\test.php(98): SoapClient->__call('GetHotelSearch', Array) #1 D:\[.Projeler]\musteri\webservis\test.php(98): SoapClient->GetHotelSearch(Array, 10, 'Ascending', Object(stdClass)) #2 {main} thrown in D:\[.Projeler]\musteri\webservis\test.php on line 98 

시도하고 잡으십시오 :

End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 155.

그래서, 나는 당신의 문제를 재현하려고 노력했고, 나는 내가 추가 할 때까지 작동하지 않는 온도 변환 을 선택했다. 나는 당신의 서비스에 접근 할 수 없었다.

$SoapCallParameters = new stdClass();
$SoapCallParameters->nCelcius = 30;
$obj = $client->CelciusToFahrenheit($SoapCallParameters); 

어쩌면 stdClass 같은 것을 사용해 볼 수도 있습니다.

$hotelSearch = new stdClass();
$hotelSearch->searchClass->BRANCHID = 000;
$hotelSearch->searchClass->UNIQUECODE = YIO;

면책 조항 : 당신은 내가 PHP를 배우는 중이라는 것을 알아야하고, 내가 배울 수있는 유일한 방법은 문제를 해결하는 것입니다. 그래서 이것은 제가 문제를 풀려고하는 것입니다.

내 작업 온도 변환 작업 코드는 아래와 같습니다.

error_reporting(E_ALL);
ini_set('display_errors', '1');
$url = "http://webservices.daehosting.com/services/TemperatureConversions.wso?WSDL";

$client = new SoapClient($url, array("trace" => 1, "exception" => 0)); 

var_dump($client->__getFunctions());

$SOAPCall = "CelciusToFahrenheit";
$SoapCallParameters = new stdClass();
$SoapCallParameters->nCelcius = 30;
$obj = $client->CelciusToFahrenheit($SoapCallParameters);
var_dump($obj);

@Sergiu Paraschiv의 도움을 받았습니다.

soapclient를 실행할 때의 내부 서버 오류





complextype