2010-07-19 4 views
4

perl 및 SOAP Lite를 사용하여 .Net 웹 서비스를 사용하려고합니다.Perl 및 SOAP Lite를 사용하는 .Net 웹 서비스

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:tns="http://mysoapnamespace.com/" 
xmlns:types="http://mysoapnamespace.com/encodedTypes"> 
    <soap:Body> 
    <tns:HellowWorld /> 
    </soap:Body> 
</soap:Envelope> 

가 어떻게 생성 할 수 SOAP 라이트를 사용하여 동일한 요청 : - 나는 .NET 클라이언트에서 웹 서비스를 사용하는 경우

그것은 다음은이 .asmx 끝점에 게시? 나는 다양한 SOAP Lite 문서와 기사를 통해 행운을 봤다.

#!/usr/bin/perl 
use SOAP::Lite 'trace', 'debug' ; 

$api_ns = "https://mysoapnamespace.com"; 
$api_url = "http://mysoapnamespace/api.asmx"; 
$action = "HelloWorld"; 

    my $soap = SOAP::Lite 
    -> readable(1) 
    -> uri($api_ns) 
    -> proxy($api_url) 
    -> on_action(sub { return "\"$action\"" }) ; 


return $soap->HellowWorld(); 

이이를 생성, 잘못된 XML :

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <HellowWorld xmlns="http://mysoapnamespace.com" xsi:nil="true" /> 
     </soap:Body> 
</soap:Envelope> 

업데이트 : 내가 피들러를 사용하여 내 서비스에 1 XML을 게시 할 때

내 '안녕하세요 반환 지금까지 나는 다음과 같은이 세계 "결과. 두 번째 글을 올리면 다음과 같은 결과를 얻습니다.

<?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:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (9, 6). ---&gt; System.InvalidOperationException: &lt;HellowWorld xmlns='http://mysoapnamespace.com'&gt; was not expected. 
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read21_HellowWorld() 
    at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer28.Deserialize(XmlSerializationReader reader) 
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 
    --- End of inner exception stack trace --- 
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) 
    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() 
    --- End of inner exception stack trace --- 
    at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() 
    at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope> 
+0

두 번째 문제는 무엇입니까? 여분의 xsi : nil 속성과 별개로 동등한 것처럼 보입니다. –

+0

잘 모르겠다. 오류가 다시 발생했다. – brendan

답변

4

문제가 발견되었습니다 - 네임 스페이스에 슬래시가 있습니다. 닷넷은 당신을 위해 그런 것들을 설명하지만 Perl로 명시 적으로 설정해야합니다. 또한 ns() 함수를 사용하여 이름 공간을 추가하는 방법을 알아 냈습니다.

올바른 XML이 생성됩니다. : http://kobesearch.cpan.org/htdocs/SOAP-Lite/SOAP/Lite.pm.html

+0

BTW, 모든 CPAN 모듈의 문서에 대한 표준 링크는 항상 http://search.cpan.org/perldoc입니까? '또는 http://search.cpan.org로 이동하여 검색 필드에 모듈 이름을 입력하십시오. 만약 당신이 정말로 * 게으른 사람이라면, 그냥 구글 "cpan "그리고 당신은 올바른 결과를 99 % 얻을 것입니다. – Ether

+0

정말 고마워! 고마워! - 당연히 펄 전문가가 아니야. – brendan

0

나는 그것이 작동 (내 $ 비누 ... 줄 끝이 줄을 추가)을 얻기 위해 다음을 수행해야했다 -

#!/usr/bin/perl 
use SOAP::Lite 'trace', 'debug' ; 

$api_ns = "https://mysoapnamespace.com/"; 
$api_url = "http://mysoapnamespace/api.asmx"; 
$action = "HelloWorld"; 

    my $soap = SOAP::Lite 
    -> readable(1) 
    -> ns($api_types,'types') 
    -> ns($api_ns,'tns') 
    -> proxy($api_url) 
    -> on_action(sub { return "\"$action\"" }) ; 


return $soap->HellowWorld(); 

이 링크는 SOAP :: 라이트를 알아내는 매우 도움이되었다 나는이 사람에게 시간을 절약 바랍니다

$soap->ns('http://schemas.xmlsoap.org/soap/envelope/',"s"); 

... 그것은 BTW 그것을 알아 낸 얻을 수있는 동안 ... :-)

했다 : 나는 Windows 서비스와 닷넷 4.5 WCF를 사용하고 있습니다 웹 서비스 서버 및 P V5.16.3을 SOAP :: Lite V 1.08로 erl (활성화)하십시오.