-1

我必须提供一个 .jsp 页面(index.jsp)以及我的 Web 服务项目用于测试目的。基本上 .jsp 页面有一个文本区域,用于读取作为字符串的肥皂请求,并在提交时肥皂响应就会出现。

我尝试使用“javax.xml.ws.Service & Dispatch”类,它工作正常。但现在我被要求提供基于 javascript/ajax 的代码。

任何人都可以帮助我解决这个问题。

我在这里提供一个示例 .wsdl 文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://zensar.com/greeting" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Greeting"
    xmlns:grtng="http://zensar.com/greeting/schema"
    targetNamespace="http://zensar.com/greeting">
    <wsdl:types>
        <xsd:schema targetNamespace="http://zensar.com/greeting">
            <xsd:import namespace="http://zensar.com/greeting/schema"
                schemaLocation="Greeting.xsd"></xsd:import>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="GreetingRequest">
        <wsdl:part element="grtng:GreetingRequest" name="GreetingRequest" />
    </wsdl:message>
    <wsdl:message name="GreetingResponse">
        <wsdl:part element="grtng:GreetingResponse" name="GreetingResponse" />
    </wsdl:message>
    <wsdl:portType name="GreetingPort">
        <wsdl:operation name="Greeting">
            <wsdl:input message="tns:GreetingRequest" />
            <wsdl:output message="tns:GreetingResponse" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="Greeting" type="tns:GreetingPort">
        <soap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="Greeting">
            <soap:operation soapAction="http://zensar.com/GreetingWS/Greeting" />
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="Greeting">
        <wsdl:port binding="tns:Greeting" name="Greeting">
            <soap:address location="http://localhost:8085/Greeting/services" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>**
4

2 回答 2

1

就个人而言,我会说直接通过 javascript 使用 Web 服务有点自虐。

在我看来,JavaScript 调用服务器端方法(使用任何可能的架构,c#、java、php 等)然后执行 CURL 请求并将响应发送回前端会容易得多。

当您可以在服务器端使用 Axis2 之类的东西来执行 SOAP 握手的样板重载时,用 javascript 手动编写一个肥皂端点似乎毫无意义。

于 2013-02-14T13:02:59.837 回答
0

你可以试试这个... http://www.ibm.com/developerworks/webservices/library/ws-wsajax/ 这篇文章详细解释了一切。

于 2013-02-14T12:52:32.697 回答