2011-04-28 1 views
0

웹 서비스에 대한 http 요청을 만들려고합니다. 테스트 XML은 webservices 테스트 입력 필드에 직접 입력 할 때 작동하고 "Invoke"를 클릭하지만 같은 것을 사용하려고 할 때 작동합니다. PHP + NuSoap을 사용하여 데이터를 분석 한 결과, 해결할 수 없었던 특이한 오류가 발생했습니다. Google에서이 문제를 해결하기 위해 노력했지만 관련성이 없습니다.PHP + NuSoap을 통한 HTTP 요청

POST /iInterface_pc2/service.asmx HTTP/1.0 
Host: 10.10.86.55 
User-Agent: NuSOAP/0.9.6dev (1.137) 
Content-Type: text/xml; charset=UTF-8 
SOAPAction: "http://www.xxxx.com.cn/TransferMaterialInfo" 
Content-Length: 722 

<?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> 
    <TransferMaterialInfo xmlns="http://www.xxxx.com.cn/"> 
    <Materiallist> 
     <Materialinfo> 
     <id>123456</id> 
     <title>Hello word</title> 
     <datetime>2011-04-23 12:12:12</datetime> 
     <contributor>Some One</contributor> 
     <materialurl>www.website.com/path/audio1.mp3</materialurl> 
     <duration>10000</duration> 
     <status>0</status> 
     <remark></remark> 
     </Materialinfo> 
    </Materiallist> 
    </TransferMaterialInfo> 
</soap:Body> 
</soap:Envelope> 

그리고 응답 : : 여기

는 요청이다 내가 요청을

<?php 
     // include soap file 
     require_once('lib/nusoap.php'); 

     // set end point 
     $endpoint = "http://10.10.86.55/iInterface_pc2/service.asmx"; 

     // create client 
     $client = new nusoap_client($endpoint); 

     if ($client->getError()) { 
     print "Soap Constructor Error: "; 
     print_r($client->getError()); 
     } 

     // Human readable 
     $request = <<<HEREDOC 

     <TransferMaterialInfo xmlns="http://www.xxxx.com.cn/"> 
     <Materiallist> 
      <Materialinfo> 
      <id>123456</id> 
      <title>Hello word</title> 
      <datetime>2011-04-23 12:12:12</datetime> 
      <contributor>Some One</contributor> 
      <materialurl>www.website.com/path/audio1.mp3</materialurl> 
      <duration>10000</duration> 
      <status>0</status> 
      <remark></remark> 
      </Materialinfo> 
     </Materiallist> 
     </TransferMaterialInfo> 
    HEREDOC; 

     $action = "http://www.xxxx.com.cn/TransferMaterialInfo"; 

     $msg  = $client->serializeEnvelope($request, '', array(), 'document', 'encoded', ''); 
     $result = $client->send($msg, $action); 

     if ($client->fault) { //soap_fault 
     print "Soap Fault :"; 
     print_r($client->fault->faultcode); 
     print_r($client->fault->faultstring); 
     } 
     elseif ($client->getError()) { 
     print "Soap Error :"; 
     print_r($client->getError()); 
     } 
     else { 
     print "Result: "; 
     print_r($result); 
     } 

     ..print stuff 
?> 

어떤 통찰력을 생성하는 데 사용할

HTTP/1.1 500 Internal Server Error 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
X-AspNet-Version: 2.0.50727 
X-Powered-By: ASP.NET 
Date: Thu, 28 Apr 2011 11:04:11 GMT 
Connection: close 
Content-Length: 428 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<soap:Body> 
<soap:Fault> 
<faultcode>soap:Server</faultcode> 
<faultstring>Server was unable to process request. ---&gt; Value cannot be null. 
Parameter name: s</faultstring> 
<detail /> 
</soap:Fault> 
</soap:Body> 
</soap:Envelope> 

그리고 마지막으로 PHP와 크게 감사 추측 . 나는 벽돌 벽에 머리를 두드리는 소리를 지어왔다. :/

+0

인수/매개 변수가 필요없는 내장 HelloWorld 메소드로부터 성공적인 응답을 얻을 수 있습니다. – red

답변

0

문제는 해결되었으며 실제로는 공백 만 html로 인코딩되어 잘못된 응답을하게되는 잘못된 ASP 코드로 인해 발생했습니다.

+0

공백이 무슨 뜻인지 이해할 수 없습니까? – atasoyh

+0

공백 문자는 단어 사이의 공백을 나타내는 컴퓨터 문자입니다. Urlencode와 일치하는 것은 % 20입니다. – red

1

를 확인합니다 만약 내가 서버가 < 및> 문자를보고하고 > 에 디코드 생각, 확실하지 않다 보내기 전에 데이터를 urlencode해야 할 수도 있습니다.

+0

필자는 이것을 시도해 보았습니다. 다시 한 번, 자신의 보낸 데이터를 urlencoding하면 SOAP 요청이 partyl 인코딩되고 부분적으로 엔터티로 왜곡됩니다. 여전히 오류가 발생합니다. – red