2010-04-13 2 views
0

NuSOAP을 사용하여 작성한 php webservice를 호출하려는 실버 라이트 응용 프로그램을 작성하고 있습니다. 여기에 웹 서비스의 WSDL은Silverlight 및 PHP nuSOAP 통신 문제

 <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:currencywebservice" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:currencywebservice"> 
- <types> 
- <xsd:schema targetNamespace="urn:currencywebservice"> 
    <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> 
    <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" /> 
    </xsd:schema> 
    </types> 
    <message name="GetAllCurrenciesRequest" /> 
- <message name="GetAllCurrenciesResponse"> 
    <part name="return" type="xsd:string" /> 
    </message> 
- <portType name="currencywebservicePortType"> 
- <operation name="GetAllCurrencies"> 
    <documentation>Get all currencies available</documentation> 
    <input message="tns:GetAllCurrenciesRequest" /> 
    <output message="tns:GetAllCurrenciesResponse" /> 
    </operation> 
    </portType> 
- <binding name="currencywebserviceBinding" type="tns:currencywebservicePortType"> 
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <operation name="GetAllCurrencies"> 
    <soap:operation soapAction="urn:currencywebservice#GetAllCurrencies" style="rpc" /> 
- <input> 
    <soap:body use="literal" namespace="urn:currencywebservice" /> 
    </input> 
- <output> 
    <soap:body use="literal" namespace="urn:currencywebservice" /> 
    </output> 
    </operation> 
    </binding> 
- <service name="currencywebservice"> 
- <port name="currencywebservicePort" binding="tns:currencywebserviceBinding"> 
    <soap:address location="http://localhost/extras/currency/currencyservice.php" /> 
    </port> 
    </service> 
    </definitions> 

나는 서비스의 PHP 측이

<?php 
// Pull in the NuSOAP code 
require_once('../../lib/tools/nusoap/nusoap.php'); 

$ns = "urn:currencywebservice"; 
// Create the server instance 
$server = new soap_server(); 
// Initialize WSDL support 
$server->configureWSDL('currencywebservice', $ns); 
$server->xml_encoding = "utf-8"; 
$server->soap_defencoding = "utf-8"; 
$server->wsdl->schemaTargetNamespace = $ns; 

$server->register('GetAllCurrencies', 
array(), 
array('return' => 'xsd:string'), 
$ns, 
$ns."#GetAllCurrencies", 
'rpc', 
'literal', 
'Get all currencies available'); 

// Define the method as a PHP function 
function GetAllCurrencies() { 
     return "test return"; 
} 
// Use the request to (try to) invoke the service 
header('Content-Type: text/xml; charset=utf8'); 
$server->service($HTTP_RAW_POST_DATA); 
?> 

이 문제가 무엇인지 저를 도와주세요입니다

The content type text/html of response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly 

예외를 제공하는 웹 서비스 호출 할 때 ?

답변

0

서비스 클라이언트 (Silverlight?)가 UTF-8 인코딩을 사용하여 text/xml 인 서비스 호출 결과를 기대하지만 PHP가 text/html으로 반환하고있는 것 같습니다. text/htmlheader 명령을 통해 다른 콘텐츠 형식을 지정하지 않는 한 PHP의 기본 콘텐츠 형식입니다.

그래서, 당신은 당신의 PHP 파일/서비스의 상단에 다음과 같은 추가 시도 할 수 있습니다 :

header('Content-Type: text/xml'); 

또한 텍스트 인코딩이 UTF-8인지 확인 할 수 있습니다.

+0

도움 주셔서 감사합니다. 작동한다면 시도해 보겠습니다. –

+0

이제 "인식 할 수없는 메시지 버전"이라는 오류 메시지가 나타납니다. 어떤 생각? –

+0

작성한 모든 코드 업데이트로 원래 질문을 업데이트하십시오. –

0

nuSoap 대신 기본 PHP SoapClient를 사용하십시오. 그것은 과거의 유물입니다.

+0

문제는 PHP의 모든 인스턴스가 기본 SoapClient가 설치/컴파일되지 않은 것입니다. Zend 프레임 워크 또는 원시 PHP SOAP 라이브러리를 사용하지만 사용 가능한 버전으로 제한됩니다. PHP를 다시 컴파일하는 여러 가지 이유가 있습니다. 따라서 NuSOAP은 두 가지 중 하나입니다. – Kingsolmn

1

등록 방법에서 '$ 사용'매개 변수를 '인코딩 된'대신 '리터럴'로 지정하십시오.

+0

작동하는지 확인하겠습니다. –