PHP - SOAP请求| XML / WSDL

I'm looking for a way to send a SOAP request from PHP code. An online game called MovieStarPlanet, has a "library" with many SOAP requests.

Here is the link to all queries:

The WSDL description:

The query is like this:

POST /WebService/ThirdParty/ThirdPartyService.asmx HTTP/1.1
Host: http://www.moviestarplanet.fr
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://moviestarplanet.com/Login"

<?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:Header>
    <ThirdPartyTokenHeader xmlns="http://moviestarplanet.com/">
      <ThirdPartyToken>string</ThirdPartyToken>
    </ThirdPartyTokenHeader>
  </soap:Header>
  <soap:Body>
    <Login xmlns="http://moviestarplanet.com/">
      <username>string</username>
      <password>string</password>
    </Login>
  </soap:Body>
</soap:Envelope>

And the answer to this query is:

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?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:Header>
    <ThirdPartyTicketHeader xmlns="http://moviestarplanet.com/">
      <Ticket>string</Ticket>
    </ThirdPartyTicketHeader>
  </soap:Header>
  <soap:Body>
    <LoginResponse xmlns="http://moviestarplanet.com/">
      <LoginResult>
        <ServiceResult>
          <Codee>int</Codee>
          <Description>string</Description>
        </ServiceResult>
        <ActorId>int</ActorId>
        <AppToken>string</AppToken>
        <UserInfo>
          <FriendCount>int</FriendCount>
          <MembershipTimeoutDate>dateTime</MembershipTimeoutDate>
          <VipTier>int</VipTier>
          <Level>int</Level>
          <LockedUntil>dateTime</LockedUntil>
          <LockedText>string</LockedText>
          <SkinSWF>string</SkinSWF>
          <LastLogin>dateTime</LastLogin>
        </UserInfo>
      </LoginResult>
    </LoginResponse>
  </soap:Body>
</soap:Envelope>

That would suggest a lot of account information when the username/password combination is correct.

I did a lot of research, but I don't know how to apply the code. Here's what I did:

$soap_request  = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
";
$soap_request .= "<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_request .= "  <soap:Header>
";
$soap_request .= "    <ThirdPartyTokenHeader xmlns=\"http://moviestarplanet.com/\">
";
$soap_request .= "      <ThirdPartyToken>8346D304-F85E-4dc1-98EB-033CBEE0217F</ThirdPartyToken>
";
$soap_request .= "    </ThirdPartyTokenHeader>
";
$soap_request .= "  </soap:Header>
";
$soap_request .= "  <soap:Body>
";
$soap_request .= "    <Login xmlns=\"http://moviestarplanet.com/\">
";
$soap_request .= "      <username>string</username>
";
$soap_request .= "      <password>string</password>
";
$soap_request .= "    </Login>
";
$soap_request .= "  </soap:Body>
";
$soap_request .= "</soap:Envelope>";

$header = array(
  "POST /WebService/ThirdParty/ThirdPartyService.asmx HTTP/1.1",
  "Host: http://www.moviestarplanet.fr",
  "Content-type: text/xml; charset=utf-8",
  "Content-length: ".strlen($soap_request),
  "SOAPAction: \"http://moviestarplanet.com/Login\"",
);

$url = "http://www.moviestarplanet.fr/WebService/ThirdParty/ThirdPartyService.asmx?WSDL";

$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url);
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST,           true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);

if(curl_exec($soap_do) === false) {
  $err = 'Curl error: ' . curl_error($soap_do);
  curl_close($soap_do);
  print $err;
} else {
  curl_close($soap_do);
  print 'Success.';
}

When I run the code, it tells me an error: "Operation timed out after 10000 milliseconds with 0 bytes received".

Anyone can help me?

查看全部
douyou2368
douyou2368
2016/09/09 16:41
  • wsdl
  • xml
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复