2012-08-07 5 views
1

많은 기능을 가진 웹 서비스 (WSDL)가 있습니다. PHP로이 함수 중 하나를 호출하고 싶습니다. webservice는 헤더와 xml을 포함한 형식을 넣는 문서를 제공하지만 PHP에서 요청을 보내는 방법을 알지 못합니다. 나는 지금 2 시간 동안 수색했다. 그리고 나는 단지 모른다.PHP로 SOAP 요청

그들이 제공 요청의 예 :

내가 받아야 응답도 주어진다
POST POSTURL HTTP/1.1 
Host: HOST 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "SOAPLOCATION" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <Version xmlns="URL" /> 
    </soap:Body> 
</soap:Envelope> 

,하지만 난 심지어는 요청을 보낼 수 없습니다.

응답을 받기 위해 PHP로 요청을 보내려면 어떻게해야합니까? PHP SoapClient를 사용해 보았지만 튜토리얼 또는 명확한 설명을 쉽게 찾을 수 없습니다 ...

누구든지 저를 도울 수 있다면 좋을 것입니다!

+0

여기를 보았습니까? http://php.net/manual/en/class.soapclient.php – Tomer

+0

그래, 나는 그것을 보았다. 그리고 나는 모른다. 나는 SoapClient를 만들 수있다. 그런 다음 클라이언트 -> __getfunctions(),하지만이 함수 중 하나를 호출하는 방법을 모르겠습니까? – RobinV91nl

답변

0

나는 질문에 추가했습니다 나는 알고 있지

Content-Type: text/xml; charset=utf-8 
SOAPAction: URI 

를 두 된 SOAPHeaders 내가 보낼 필요가있다

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns="..."> 
    <s:Body> 
     <Search> 
     <login> 
      <Wholesaler>...</Wholesaler> 
      <Username>...</Username> 
      <Password>...</Password> 
     </login> 
     <itemRequests> 
      <ItemRequest> 
       <ArticleId>int</ArticleId> 
       <SupplierId>int</SupplierId> 
       <QuantityRequested>int</QuantityRequested> 
      </ItemRequest> 
     </itemRequests> 
     </Search> 
    </s:Body> 
</s:Envelope> 

서비스 제공자 및 동작 식별자를 포함한다. 나는 다음과 같은 변수

$service 
$action 
$request 
$header 

이있는 경우

어떻게 PHP에서 요청을 보낼 수 있습니까? 내가

$client = new SoapClient($service); 
$result = $client->__doRequest($request, $service, $action); 

을 시도하지만 그것은 보인다 응답을 ...받지 못한

이 응답이 좋아한다 무엇 :

Date: Thu, 09 Aug 2012 08:01:40 GMT 
Server: Microsoft-IIS/6.0 
X-Powered-By: ASP.NET 
X-AspNet-Version: 4.0.30319 
Content-Length: 408 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 


<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <SearchResponse xmlns="..."> 
     <SearchResult> 
     <Wholesaler>...</Wholesaler> 
     <Username>...</Username> 
     <Error>false</Error> 
     <DateTime>2012-08-09T10:01:40.39125+02:00</DateTime> 
     <ItemResults /> 
     </SearchResult> 
    </SearchResponse> 
    </s:Body> 
</s:Envelope> 

나는 간단한 에코 $ 결과를 할

, 화면은 흰색으로 유지되고 코드에는 XML이 표시되지 않습니다.

+0

나는 그것을 고쳤다 ... DOM – RobinV91nl

0

몇 가지 일반적인 정보를 매핑하면 다음과 같이 표시 될 수 있습니다. 응답 후 처리

 $data = array(
     'UserName' => $user->getUsername(), 
     'Password' => $user->getPassword(), 
     'Email'  => $user->getEmail(), 
     'FirstName' => $user->getFirstName(), 
     'LastName' => $user->getLastName(), 
    ); 


    $response = $this->getDatasource()->TheServiceMethodForCreatingAUser(
     array(
      'user' => $data 
     ) 
    ); 

그러나 당신은 (일부 설명의 기관 또는 응답 객체를 통해) 바랍니다. 헤더는 새로운 SoapHeader()를 사용하여 별도로 수행해야합니다.

희망이 도움이됩니다. 다음과 같은

요청한다 :