2012-09-10 6 views
0

몇 달 전에이 질문을했지만 웹 서비스가 올바르게 작동하지 않는 것이 문제였습니다. 이제는 완벽하게 작동하고 있으며 여전히 간단한 요청을하는 데 문제가 있습니다. 우선, 시도해 보니 http://www.validwsdl.com/ WS는 http://amibcertifica.amib.com.mx:9090/axis2/services/JpaWebServicesAmib?wsdl 당신 스스로 시도 할 수 있습니다. 해당 웹 사이트에서 정상적으로 작동합니다. 지금은 NuSOAP와 요청을 만들려고 노력하고있어 나는이 오류를 얻을 : namespace mismatch require http://ws.mobius.amib found http://tempuri.orgNuSOAP (클라이언트 측)을 사용하여 네임 스페이스를 설정하는 방법

당신이있어 전체 오류를 확인할 수 있습니다 :

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

$url = "http://amibcertifica.amib.com.mx:9090/axis2/services/JpaWebServicesAmib?wsdl"; 


try 
{ 
    $client = new nusoap_client($url); 
    $err = $client->getError(); 
if ($err) { 
    // Display the error 
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; 
    // At this point, you know the call that follows will fail 
} 
    $result = $client->call('findAllComprobanteOperacion'); 
} 
catch (SoapFault $e) 
{ 
    echo 'Error0'.$e->getMessage() . "\n"; 
} 

echo '<pre>';print_r($result); 
echo $client->debug_str; 
?> 

: http://dev.etic.com.mx/bmv/test.php

내 코드는 다음과 같다 NuSOAP 버전 : $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $

나는 웹을 통해이 작업을 수행하는 방법을 모색 해 왔으며 완전히 단서가 없으므로 도움을 얻을 수 있습니다. 미리 감사드립니다.

답변

1

생각보다 간단했습니다. 방금 nusoap_client의 두 번째 매개 변수를 TRUE로 설정해야했습니다 (기본적으로 FALSE이기 때문에). 따라서, 그것은 $client = new nusoap_client($url, TRUE); 입니다. 어쨌든 고마워, .

+0

남자 야! 너 sth 알아? 너는 내 천사 야! 고마워요! nusoap 소스 코드를 검색 및 디버깅하고 탐색 한 후 백만 가지를 테스트 한 결과, 귀하의 답변이 완성되었습니다! – Abadis

1

네임 스페이스를 인수로 선언하여 설정합니다. 기본적으로 네임 스페이스는 "http://tempuri.org"(일부 비누 서버에는 'http://tempuri.org/'과 같은 추가 슬래시가 필요합니다)로 설정됩니다.

$result = $client->call('findAllComprobanteOperacion', null, 'http://tempuri.org/'); 

또한 다음과 같이 당신의 인수를 선언하고 SOAPAction이고, 네 번째 인수를 설정할 수 있습니다 : 당신이 전화 기능을 사용할 때,이 같은 세 번째 인수에 네임 스페이스를 설정할 수 있습니다

$result = $client->call('findAllComprobanteOperacion', array('Argument1' => 'value1', 'Argument2' => 'value2'), 'http://tempuri.org/', 'SoapActionHere'); 

기본적으로 NuSoap은 1000에서 9999 사이의 임의의 숫자를 네임 스페이스의 접두사 (변수 이름)로 강제 설정합니다. 이는 서버가 싫어할 수도 있습니다. 이 문제를 실제로 수정하는 방법은 없습니다. 간단히이 문제를 해결하기 위해 nusoap.php를 편집했습니다. 라인 7431 (또는 그 부근)에서 찾을 수 있습니다 :에

$this->debug("wrapping RPC request with encoded method element"); 
if ($namespace) { 
// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace 
    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . 
      $payload . "</$nsPrefix:$operation>"; 
} else { 
    $payload = "<$operation>" . $payload . "</$operation>"; 
} 

변화를 :

if ($namespace) { 
    $payload = "<$operation xmlns=\"$namespace\">" . 
     $payload . "</$operation>"; 
} else { 
    $payload = "<$operation>" . 
      $payload . "</$operation>"; 
}