- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在尝试用 Java 创建一个 Web 服务客户端。我不知道该怎么做。这是 WSDL 的 URL:https://testservices.gatewayedi.com/PayerList/payerlist.asmx?wsdl
这是 WSDL:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="https://ws.gatewayedi.com/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="https://ws.gatewayedi.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="https://ws.gatewayedi.com/">
<s:element name="Ping">
<s:complexType />
</s:element>
<s:element name="PingResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PingResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AuthSOAPHeader" type="tns:AuthSOAPHeader" />
<s:complexType name="AuthSOAPHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="User" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
<s:anyAttribute />
</s:complexType>
<s:element name="GetXMLPayerList">
<s:complexType />
</s:element>
<s:element name="GetXMLPayerListResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetXMLPayerListResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getDocLinks">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="pid" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getDocLinksResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="getDocLinksResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="PingSoapIn">
<wsdl:part name="parameters" element="tns:Ping" />
</wsdl:message>
<wsdl:message name="PingSoapOut">
<wsdl:part name="parameters" element="tns:PingResponse" />
</wsdl:message>
<wsdl:message name="PingAuthSOAPHeader">
<wsdl:part name="AuthSOAPHeader" element="tns:AuthSOAPHeader" />
</wsdl:message>
<wsdl:message name="GetXMLPayerListSoapIn">
<wsdl:part name="parameters" element="tns:GetXMLPayerList" />
</wsdl:message>
<wsdl:message name="GetXMLPayerListSoapOut">
<wsdl:part name="parameters" element="tns:GetXMLPayerListResponse" />
</wsdl:message>
<wsdl:message name="GetXMLPayerListAuthSOAPHeader">
<wsdl:part name="AuthSOAPHeader" element="tns:AuthSOAPHeader" />
</wsdl:message>
<wsdl:message name="getDocLinksSoapIn">
<wsdl:part name="parameters" element="tns:getDocLinks" />
</wsdl:message>
<wsdl:message name="getDocLinksSoapOut">
<wsdl:part name="parameters" element="tns:getDocLinksResponse" />
</wsdl:message>
<wsdl:message name="getDocLinksAuthSOAPHeader">
<wsdl:part name="AuthSOAPHeader" element="tns:AuthSOAPHeader" />
</wsdl:message>
<wsdl:portType name="PayerListSoap">
<wsdl:operation name="Ping">
<wsdl:input message="tns:PingSoapIn" />
<wsdl:output message="tns:PingSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetXMLPayerList">
<wsdl:input message="tns:GetXMLPayerListSoapIn" />
<wsdl:output message="tns:GetXMLPayerListSoapOut" />
</wsdl:operation>
<wsdl:operation name="getDocLinks">
<wsdl:input message="tns:getDocLinksSoapIn" />
<wsdl:output message="tns:getDocLinksSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PayerListSoap" type="tns:PayerListSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Ping">
<soap:operation soapAction="https://ws.gatewayedi.com/Ping" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:PingAuthSOAPHeader" part="AuthSOAPHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetXMLPayerList">
<soap:operation soapAction="https://ws.gatewayedi.com/GetXMLPayerList" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:GetXMLPayerListAuthSOAPHeader" part="AuthSOAPHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getDocLinks">
<soap:operation soapAction="https://ws.gatewayedi.com/getDocLinks" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:getDocLinksAuthSOAPHeader" part="AuthSOAPHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="PayerListSoap12" type="tns:PayerListSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Ping">
<soap12:operation soapAction="https://ws.gatewayedi.com/Ping" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:PingAuthSOAPHeader" part="AuthSOAPHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetXMLPayerList">
<soap12:operation soapAction="https://ws.gatewayedi.com/GetXMLPayerList" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:GetXMLPayerListAuthSOAPHeader" part="AuthSOAPHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getDocLinks">
<soap12:operation soapAction="https://ws.gatewayedi.com/getDocLinks" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header message="tns:getDocLinksAuthSOAPHeader" part="AuthSOAPHeader" use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PayerList">
<wsdl:port name="PayerListSoap" binding="tns:PayerListSoap">
<soap:address location="https://testservices.gatewayedi.com/PayerList/payerlist.asmx" />
</wsdl:port>
<wsdl:port name="PayerListSoap12" binding="tns:PayerListSoap12">
<soap12:address location="https://testservices.gatewayedi.com/PayerList/payerlist.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
服务中有三种方法。
我正在尝试使用 SOAP 调用此方法。
XML 消息格式为:
POST /PayerList/payerlist.asmx HTTP/1.1
Host: testservices.gatewayedi.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: <<insert message length here>>
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <AuthSOAPHeader xmlns="https://ws.gatewayedi.com/"> <User><<insert user id here>>
</User>
<Password><<insert user web password here>> </Password>
</AuthSOAPHeader>
</soap12:Header> <soap12:Body> <Ping xmlns="https://ws.gatewayedi.com/" />
</soap12:Body>
</soap12:Envelope>
任何知道解决方案的人请告诉我。任何帮助都是非常可观的。
最佳答案
正如对 Jon's answer 的评论中所暗示的那样,我的建议是使用 JAX-WS RI(包含在 Java 6 中)或 Apache CXF 之类的 JAX-WS 实现。
我将使用 JAX-WS RI 来说明我的答案,因为它在命令行上开箱即用(解释步骤),但我建议使用具有良好 JAX-WS 支持的 IDE,例如NetBeans(请参阅答案末尾的资源)。
第一次运行 wsimport
生成 JAX-WS 工件(简而言之,您需要调用 Web 服务的类):
wsimport -d generated -extension -keep -p com.gatewayedi.ws -XadditionalHeaders https://testservices.gatewayedi.com/PayerList/payerlist.asmx?wsdl
关于选项:
-d
用于指定生成的东西的目标目录-extension
用于允许扩展(WSDL 使用的是非标准 SOAP 1.2 绑定(bind))-keep
是保留生成的.java
源代码(这样便于开发)-p
用于为生成的工件指定一个包-XadditionalHeaders
用于map additional WSDL headers (that are not part of the input or output contract defined in the portType
operation) to method parameters (这将使调用服务更容易)。对不起,如果有些词汇是晦涩难懂的,但是,欢迎使用 SOAP Web 服务 :)
这是一个简单的客户端,展示了如何使用生成的类调用其中一个可用的操作:
import com.gatewayedi.ws.AuthSOAPHeader;
import com.gatewayedi.ws.PayerList;
import com.gatewayedi.ws.PayerListSoap;
public class Main {
public static void main(String[] args) {
new Main().callWebService();
}
private void callWebService() {
PayerList service = new PayerList();
PayerListSoap port = service.getPayerListSoap();
AuthSOAPHeader authSOAPHeader = new AuthSOAPHeader();
authSOAPHeader.setUser("test");
authSOAPHeader.setPassword("test");
String payerList = port.ping(authSOAPHeader);
System.out.println(payerList);
}
}
下面,生成的请求:
<?xml version="1.0" standalone="no"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<AuthSOAPHeader xmlns="https://ws.gatewayedi.com/">
<User>test</User>
<Password>test</Password>
</AuthSOAPHeader>
</S:Header>
<S:Body>
<Ping xmlns="https://ws.gatewayedi.com/"/>
</S:Body>
</S:Envelope>
不知道你应该通过什么凭据。
关于java - 给定 WSDL 的 Web 服务客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4172118/
为什么 WSDL 引入 wsdl:message?和消息部分? 与在操作参数(输入、输出、故障)中直接使用 XSD 相比,他们可以带来什么优势? 它们(带有 wsdl 消息部分的 wsdl 消息)如何
这个问题看起来很简单,但我找不到合适的地方在 WSDL 文档中设置其定义的版本。 目标是能够很容易地看到它何时过时,以及我将来何时更新它。 我要把它设为 1.0。如果将来我向它添加新操作,我将其设置为
在 WSDL 文件中,函数可以返回类型或元素。到目前为止,我仅使用自定义类型作为结果。但是,我想知道什么时候Element应该比Type更合适?它们有什么区别? 有什么区别吗 和
我在 web sphere 服务器上部署了一个 jax-ws web 服务,当我尝试使用 url 在浏览器中访问 wsdl 时 "Http://localhost:7001/HelloWorldSer
我在使用 SVCUtil 为 WCF 生成代理时遇到错误。错误是 Attempting to download metadata from 'net.pipe://localhost/WebServi
我正在遵循 WSDL-first(由我们的客户提供)方法来开发 WCF 服务,但是从我的 wcf 服务生成的 WSDL 与我们的客户提供给我的 WSDL 略有不同,并且由于这种不匹配,客户在调用我的服
我有嵌套的 WSDL,我想将其扁平化。 wsdl 导入 xsd 文件,这些文件又包含其他文件等。我喜欢把整个东西压平成一个文件,以便将它提供给一个无法执行导入/包含的工具。有没有我可以使用的简单工具(
我正在尝试使用一些统计信息进行 WSDL 解析(使用 c#.net)。我的统计数据取决于 WSDL 中的文档标签。我想知道可以包含文档标签的 wsdl 标签列表来检查它们。 我试图阅读 WS-I 基本
我有一个 WSDL 文件。我想将 wsdl 文件转换为 Web 服务类文件。 是否可以?如果是,请向我详细解释。 最佳答案 在解决方案资源管理器中右键单击 您的项目并转到“添加服务 引用...” 按窗
我正在使用 Axis 为示例 WebService 建模。我现在正在做的是试图了解自动化 wsdl 和代码生成的局限性。 现在对于一些服务器端代码: 这是示例 Web 服务的框架: public cl
我有一个 Silverlight 应用程序,它通过 WCF 服务与服务器端的 ADO.Net 数据实体通信。实际上,我正在使用多个 WCF 服务与三个不同的数据 ADO.Net 数据实体进行通信。我最
是否有使用服务端点地址获取服务 WSDL 的通用方法。我知道这可以通过将 ?wsdl 附加到 Axis2 服务来完成。但是这个属性是否也适用于其他 Web 服务容器? 最佳答案 ?wsdl 适用于所有
例如使用 png归档其 mime-type是“图像/png”;那么 wsdl 的 MIME 类型是什么?文件 ? 最佳答案 text/xml - WSDL 是基于 XML 格式的服务描述。 您可以在“
我的服务是从一个 wsdl 文件中选取的。但是发布的服务 wso2 是 chenged。如果我希望 wso2 像我的 wsdl 文件一样发布。如何设置?例如,我的 wsdl 文件是:
我需要在给定 XSD 文件的情况下生成 WSDL 文件。我该怎么做呢?我可以在VS2005中这样做吗?最简单的方法是什么? 最佳答案 你不能 - XSD 描述数据方面,例如Web 服务的功能 - WS
有什么方法可以从 wsdl 生成 xsd 吗?任何链接或工具也可以。最简单的方法是什么? 最佳答案 您可以使用SoapUI:http://www.soapui.org/这是一个通常很方便的程序。创建一
我启动我的 azure 应用程序,浏览到 svc 文件 http://127.0.0.1:82/transaction.svc ,我得到了通常的结果: You have created a servi
我使用动态端点 wsdl(通过 http 的 wsdl)来生成客户端。这工作得很好。 是否可以从动态wsdl的http链接生成静态wsdl? 问题是动态 wsdl 只能从一台机器访问。 我想在另一台电
我想知道是否可以将请求从一个 wsdl 发送到另一个 wsdl。如果是,那我该怎么做? 流程将是: 我想使用 switchyard 公开一个 wsdl,比如 wsdl-1,它可能有 100 个参数,带
我按照定义的步骤使用 Spring Boot 创建了一个网络服务 here当我尝试下载 wsdl 时,我不得不在 url 中使用 .wsdl 。但是,当我使用 ?wsdl 时,不会下载 wsdl。当我
我是一名优秀的程序员,十分优秀!