首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法使用WSDL::Generator运行Perl web服务

无法使用WSDL::Generator运行Perl web服务
EN

Stack Overflow用户
提问于 2012-04-13 17:10:29
回答 1查看 1.9K关注 0票数 16

两个星期以来,我一直在尝试用Perl (使用WSDL::Generator)创建一个web服务,并用一个用Perl编写的客户端调用它。

现在,我尝试了专门用于WSDL:Soap::Lite的库提供的示例,但是我得到了一个错误,并且一直出现

代码语言:javascript
复制
404 file not found at c.PL at line 7.

你能帮我解决吗?

下面是我的代码:

WorldFunctions.pm (C:\Perl\SOAP-Lite\WorldFunctions.pm):类

代码语言:javascript
复制
package WorldFunctions;
    sub new { bless {}, shift; }
    sub Hello { my ($s, $name) = @_;
            return 'Hello, ' . $name . "\n";
    }
    sub GoodBye { my ($s, $name) = @_;
            return 'Goodbye, ' . $name . "\n";
    }

a.pl (C:\Perl\SOAP-Lite\a.pl):创建类WorldFunctions.pm的WSDL文件

代码语言:javascript
复制
#!/usr/bin/perl
use WSDL::Generator;
my $init = {
        'schema_namesp' => 'http://localhost/world/WorldFunctions.xsd',
        'services'      => 'WorldFunctions',
        'service_name'  => 'WorldFunctions',
        'target_namesp' => 'http://localhost/world',
        'documentation' => 'Simple Hello World SOAP Service.',
        'location'      => 'http://localhost/world'
};
my $w = WSDL::Generator->new($init);
WorldFunctions->Hello('Joe');
WorldFunctions->GoodBye('Joe');
print $w->get(WorldFunctions); # Returns the WSDL code for a specific class
open(TOTO,"<a.wsdl");
close(TOTO);
open(TOTO,">a.wsdl");
print TOTO $w->get(WorldFunctions);
close(TOTO);

c.pl (C:\ perl \SOAP-Lite\c.pl):perl client WSDL文件

代码语言:javascript
复制
#!/usr/bin/perl 
use DBI();
use CGI;
use SOAP::Lite;
my $service = SOAP::Lite-> service('file:a.wsdl');   
print "test retour : |".$service-> Hello('Joe')."|";

知道我使用的是本地服务器(带有WAMP服务器)并将其复制到我的目录WorldFunctions.pm localhost / world中。

下面是WSDL文件:

代码语言:javascript
复制
<?xml version="1.0"?>
<definitions name="WorldFunctions" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://localhost/world" xmlns:tns="http://localhost/world" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsdl="http://localhost/world/WorldFunctions.xsd">
    <types>
        <xsd:schema targetNamespace="http://localhost/world/WorldFunctions.xsd">
            <xsd:element name="GoodByeRequest" type="xsd:string" />
            <xsd:element name="GoodByeResponse" type="xsd:string" />
            <xsd:element name="HelloRequest" type="xsd:string" />
            <xsd:element name="HelloResponse" type="xsd:string" />
        </xsd:schema>
    </types>
    <message name="GoodByeRequest">
        <part name="GoodByeRequestSoapMsg" element="xsdl:GoodByeRequest"/>
    </message>
    <message name="GoodByeResponse">
        <part name="GoodByeResponseSoapMsg" element="xsdl:GoodByeResponse"/>
    </message>
    <message name="HelloRequest">
        <part name="HelloRequestSoapMsg" element="xsdl:HelloRequest"/>
    </message>
    <message name="HelloResponse">
        <part name="HelloResponseSoapMsg" element="xsdl:HelloResponse"/>
    </message>
    <portType name="WorldFunctionsWorldFunctionsPortType">
        <operation name="GoodBye">
            <input message="tns:GoodByeRequest" />
            <output message="tns:GoodByeResponse" />
        </operation>
        <operation name="Hello">
            <input message="tns:HelloRequest" />
            <output message="tns:HelloResponse" />
        </operation>
    </portType>
    <binding name="WorldFunctionsWorldFunctionsBinding" type="tns:WorldFunctionsWorldFunctionsPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="GoodBye">
                <soap:operation style="document" soapAction=""/>
                <input>
                    <soap:body use="literal"/>
                </input>
                <output>
                    <soap:body use="literal"/>
                </output>
            </operation>
            <operation name="Hello">
                <soap:operation style="document" soapAction=""/>
                <input>
                    <soap:body use="literal"/>
                </input>
                <output>
                    <soap:body use="literal"/>
                </output>
            </operation>
    </binding>
    <service name="WorldFunctions">
        <documentation>
            Simple Hello World SOAP Service.
        </documentation>
        <port name="WorldFunctionsWorldFunctionsPort" binding="tns:WorldFunctionsWorldFunctionsBinding">
            <soap:address location="http://localhost/world"/>
        </port>
    </service>
</definitions>
EN

回答 1

Stack Overflow用户

发布于 2013-12-13 16:16:52

看起来您没有将http://localhost/world映射到可以处理该请求的SOAP处理程序,因此您将获得该URL404。

您需要配置apache,这样才能在该URL中找到某些内容。

http://metacpan.org/pod/SOAP::WSDL::Server::Mod_Perl2

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10138127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档