【发布时间】:2013-02-14 12:44:50
【问题描述】:
我必须提供一个 .jsp 页面 (index.jsp) 以及我的 Web 服务项目以用于测试目的。 基本上 .jsp 页面有一个 textarea,用于读取作为字符串的 soap 请求并在提交它时会收到soap 响应。
我尝试使用“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>**
【问题讨论】:
-
我会考虑在相同的业务逻辑上编写一个基于 JAX-RS/JSON 的服务。这应该比尝试从 Javascript 使用 SOAP 痛苦得多
-
JAX-WS 也可能支持 JSON+plain HTTP 端点用于“常规”/非 REST Web 服务。
标签: java javascript ajax web-services soap-client