wsdl 相关问题

Web服务描述语言(WSDL)是一种基于XML的人类和机器可读语言,用于描述Web服务。它描述了可用的Web服务方法,消息请求和响应结构,可能的故障以及通信和安全要求。此标记不引用任何名为“wsdl”的工具,例如Microsoft的WSDL.EXE。

从c#访问Web服务时出现500内部服务器错误

我已经被这个问题难住有一段时间了。我正在尝试根据 WSDL 文件中的信息创建 SOAP 请求,以发送到 Web 服务并检索响应。从...

回答 3 投票 0

JAXB 无法从soap (WSDL) 服务获取附件

我需要调用返回附件的 SOAP 服务。 定义“附加”数据的 XSD 是 我需要调用返回附件的 SOAP 服务。 定义“附加”数据的 XSD 是 <xs:complexType name="transferableFileData"> <xs:complexContent> <xs:extension base="tns:transferableFile"> <xs:sequence> <xs:element name="fileData" type="xs:base64Binary" minOccurs="0"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> 我在 pom.xml 文件中使用此插件从 WSDL 和 XSD 文件生成类 <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.15.1</version> </plugin> 自动生成的类是这样的 @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "transferableFileData", propOrder = { "fileData" }) public class TransferableFileData extends TransferableFile { protected byte[] fileData; public byte[] getFileData() { return fileData; } public void setFileData(byte[] value) { this.fileData = value; } } 服务器的响应是: Cache-Control: max-age=0 Cache-Control: no-cache Cache-Control: no-store Server-Timing: ak_p; desc="1705942361025_1611673733_335963847_52691_3577_46_71_-";dur=1 Server-Timing: origin; dur=520 Server-Timing: edge; dur=7 Server-Timing: cdn-cache; desc=MISS Connection: keep-alive Set-Cookie: LtpaToken2=Jss03JN+gXMYTd; Path=/; HttpOnly Expires: Mon Expires: 22 Jan 2024 16:52:41 GMT Pragma: no-cache Content-Length: 2912 Content-Language: en-US Date: Mon Date: 22 Jan 2024 16:52:41 GMT Content-Type: Multipart/Related; boundary="----=_Part_11_2001319686.1705942360849"; type="application/xop+xml"; start-info="text/xml" SOAPAction: "" Accept: text/xml ------=_Part_11_2001319686.1705942360849 Content-Type: application/xop+xml; charset=utf-8; type="text/xml" Content-Transfer-Encoding: binary Content-ID: <[email protected]> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns2:downloadPendingFileResponse xmlns:ns2="http://iris.somewhere.cp,/web_services/external/downloadFile" xmlns:ns3="http://iris.somewhere.com/web_services/external/uploadFile"><downloadPendingFileResult><fileExchangeNo>1174649</fileExchangeNo><fileName>TEST00001_2024-01-22-18.46.08.00000_APA.zip</fileName><fileData><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:[email protected]"/></fileData></downloadPendingFileResult></ns2:downloadPendingFileResponse></soapenv:Body></soapenv:Envelope> ------=_Part_11_2001319686.1705942360849 Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-ID: <[email protected]> � ������f��G��v�+p�,���� ��K�ɁZt �K�>b�La���^m��_э���1$�t�dqV�A;�ف� F�K�� ��ކO�X![ 我的Java代码是这样的: if (response instanceof JAXBElement) { DownloadPendingFileResponse downloadPendingFileResponse = ((JAXBElement<DownloadPendingFileResponse>) response).getValue(); if(downloadPendingFileResponse == null) { 及以后 final TransferableFileData transferableData = response.getDownloadPendingFileResult(); ... byte[] bytes = transferableData.getFileData(); log.info("length {}", bytes.length); 但是长度始终为零。看来我无法正确获取文件。 我注意到 WSDL 将 fileData 元素定义为 base64Binary,而 POJO 将它们定义为 byte[]。数据流似乎没有被整理。知道如何解决这个问题吗? 我在 WSDL 服务上获得了完全相同的 XSD <complexType name="myType"> <sequence> ... <element name="myFile" type="xsd:base64Binary"/> ... </sequence> </complexType> 这由 org.apache.cxf:cxf-codegen-plugin : 生成 @XmlElement(required = true) protected byte[] myFile; 但是为了进行解组,我必须将 XSLT 设置为 jaxws:feature spring 客户端,以便告诉 CXF 理解响应中的 href(文件 transform.xsl 的内容如下): <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" > <xsl:key name="multiref-by-id" match="multiRef" use="@id"/> <xsl:template match="/"> <xsl:copy> <xsl:apply-templates select="@*|*"/> </xsl:copy> </xsl:template> <xsl:template match="*[starts-with(@href, '#')]"> <xsl:copy> <xsl:apply-templates select="@* | key('multiref-by-id', substring-after(@href, '#'))/@* | key('multiref-by-id', substring-after(@href, '#'))/node()"/> </xsl:copy> </xsl:template> <xsl:template match="@href[starts-with(., '#')] | multiRef[@id] | @soapenc:root"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> 这是在 XML Spring Config 中定义的 bean : <bean id="xsltFeature" class="org.apache.cxf.feature.transform.XSLTFeature"> <property name="inXSLTPath" value="transform.xsl" /> <property name="outXSLTPath" value="transform.xsl" /> </bean> <jaxws:client id="myService" serviceClass="my.web.Service" address="myurl"> <jaxws:features> <ref bean="xsltFeature" /> </jaxws:features> </jaxws:client> 通过这样做,我可以通过Java中的myFile的getter读取附件的内容,而无需额外的配置。 我认为您可以对其进行调整,以使其在您自己的应用程序上下文中工作。

回答 1 投票 0

Java、WSDL 生成的类无法转换为 javax.xml.bind.JAXBElement

我在调用 Web 服务后返回 javax.xml.bind.JAXBElementException。 JAXBElement jAXBElement = new ObjectFactory().createShowPendingFiles(showPendingFilesRe...

回答 1 投票 0

ASP.NET Core MVC:WCF 客户端不包含采用 0 个参数的构造函数

我有一个带有 WCF 的 ASP.NET Core MVC 项目。我使用 IIS 将 WCF 发布到远程服务器,并通过以下方式使用客户端: 右键单击“连接服务”> 管理连接服务...

回答 1 投票 0

Wsdl2Java 生成带有 protected List 的类<JAXBElement<?>> content

我们正在尝试与 https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/taiif/wsdl/ixgd/DpiNtnlDeclaration_v1.0.wsdl 中发布的服务集成 我们已经配置了我们的 g...

回答 1 投票 0

从现有 WSDL 构建 Django WebService

我需要重写现有的 WebService 作为 Django 应用程序的一部分,目标是将 Django 应用程序集成到只能调用此特定 WebService 的遗留系统中。 所以我...

回答 1 投票 0

如何在 Soap Request Java 中设置标头

我在形成 SOAP 请求时遇到问题。 在该请求中,我应该在标头部分而不是有效负载部分中添加用户名、密码和一些其他信息。 在 wsdl 的条目下面 我在形成 SOAP 请求时遇到问题。 在该请求中,我应该在标头部分而不是有效负载部分中添加用户名、密码和其他一些信息。 wsdl 条目下方 <wsdl:message name="InputUploadCustomerDocument_Headers"> <wsdl:part name="DocumentType" element="tns:DocumentType"/> <wsdl:part name="FileName" element="tns:FileName"/> <wsdl:part name="Password" element="tns:Password"/> <wsdl:part name="PinNo" element="tns:PinNo"/> <wsdl:part name="UserName" element="tns:UserName"/> </wsdl:message> <wsdl:message name="ReturnUploadCustomerDocument"> <wsdl:part name="parameters" element="tns:ReturnUploadCustomerDocument"/> </wsdl:message> <wsdl:operation name="UploadCustomerDocument"> <soap:operation soapAction="http://tempuri.org/ISend/UploadCustomerDocument" style="document"/> <wsdl:input name="InputUploadCustomerDocument"> <soap:header message="tns:InputUploadCustomerDocument_Headers" part="DocumentType" use="literal"/> <soap:header message="tns:InputUploadCustomerDocument_Headers" part="FileName" use="literal"/> <soap:header message="tns:InputUploadCustomerDocument_Headers" part="Password" use="literal"/> <soap:header message="tns:InputUploadCustomerDocument_Headers" part="PinNo" use="literal"/> <soap:header message="tns:InputUploadCustomerDocument_Headers" part="UserName" use="literal"/> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="ReturnUploadCustomerDocument"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> 下面的InputUploadCustomerDocument Java文件,该文件没有用户名,密码和其他字段,我需要在reuqest之前设置这些参数 @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "fileData" }) @XmlRootElement(name = "InputUploadCustomerDocument") public class InputUploadCustomerDocument { @XmlElement(name = "FileData", required = true) protected byte[] fileData; /** * Gets the value of the fileData property. * * @return * possible object is * byte[] */ public byte[] getFileData() { return fileData; } /** * Sets the value of the fileData property. * * @param value * allowed object is * byte[] */ public void setFileData(byte[] value) { this.fileData = value; } } 这是我需要调用的函数 @WebMethod(operationName = "UploadCustomerDocument", action = "http://tempuri.org/ISend/UploadCustomerDocument") @WebResult(name = "ReturnUploadCustomerDocument", targetNamespace = "http://tempuri.org/", partName = "parameters") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) public ReturnUploadCustomerDocument uploadCustomerDocument( @WebParam(name = "InputUploadCustomerDocument", targetNamespace = "http://tempuri.org/", partName = "parameters") InputUploadCustomerDocument parameters); 有人可以帮助我如何设置这些标题吗? 您可以使用下面的行在发出请求之前添加标头,因为您使用的是 JAX-WS: SOAPHeader header = envelope.addHeader(); 有很多教程可以参考。转到 google 并搜索消费 SOAP Web 服务。这是一个这样的教程,您可以参考: http://www.javadb.com/using-a-message-handler-to-alter-the-soap-header-in-a-web-service-client/ 这是您可以使用的另一个很好的例子: https://soa2world.blogspot.com/2009/05/direct-web-service-client-using-java.html 希望这有帮助。

回答 1 投票 0

如何从 wsdl 生成 Web 服务

客户端向我提供了 wsdl 来生成 Web 服务。但是当我使用 wsdl.exe 命令时,它生成了 .cs 类。我在我的网络服务中使用了该课程,当我提供 ws 时...

回答 6 投票 0

使用 JAX-WS 从 Web 服务返回自定义对象

问题有点长,但我想提前提供所有信息 我有以下课程: 包test.api.soap.server; 公共类测试类A { 公共测试A级...

回答 1 投票 0

使方法参数不合格

亲爱的, 我正在尝试构建 WCF Web 服务 我有一个带有参数列表的网络方法 如下面的代码: [ServiceContract(命名空间 = "http://com.mwafaqat.update.ws")] 公共接口

回答 1 投票 0

Onvif wsdl 的 wsimport - 无服务定义

有几个类似的问题,但没有一个明确回答这个问题。 我使用 wsimport 从 .wsdl 文件(Onvif 的 wsdl 文件)生成代码。跑步 wsimport -保留 https://www...

回答 2 投票 0

WSDL 文件具有未定义的命名空间“ns1”和“xs”?

对 SOAP 和 WSDL 来说还是很陌生,但我有几个简单的问题。我在使用的 WSDL 文件中看到如下所示的部分,但名称空间 ns1 未在任何地方定义?元素

回答 1 投票 0

Onvif - 解析来自 WS-BaseNotification 的事件通知

我目前正在为 Onvif 实现一个事件处理程序。但我对 WS-BaseNotification 的解组过程完全迷失了。 我如何理解/解析NotificationMessageHolderT...

回答 1 投票 0

如何在 cxf v4 中取消反转包名称?

使用 org.apache.cxf cxf-codegen-插件 在一个新项目中,使用 v3.6.2 生成的客户端 java 类...

回答 1 投票 0

使用 WSDL Web 服务时底层连接被关闭

我正在尝试使用此 WSDL 服务: 转运时间服务 我第一次成功连接并得到响应,但在后续调用中我收到异常: 底层连接...

回答 1 投票 0

“com.ctc.wstx.exc.WstxUnexpectedCharException:序言中出现意外字符“H”(代码 72);预计'<' ”

我有一个用于上传文档的肥皂服务,通过它我可以上传多个文档。该服务工作正常,但偶尔会失败,并出现以下错误 - com.ctc.wstx.exc。

回答 1 投票 0

如何删除 SOAPElement 中的前缀和命名空间?

同事们,我有一个循环可以创建具有必要结构的soap xml(不要问结构) log.info("正文元素:"); NodeList nodeList = body.getElementsByTagName("*") ; 对于(int我...

回答 2 投票 0

在 JAX-WS Web 服务中实现 WS-Policy

我正在使用 JAX-WS 用 Java 开发 SOAP Web 服务。我正在使用 Eclipse Juno 和 Weblogic 12c。该 Web 服务正在 EJB 项目中开发。我正在使用自上而下的方法:从 WSDL t...

回答 1 投票 0

调用 SOAP 时,“底层连接已关闭:预期保持活动状态的连接已被服务器关闭”

在调用另一个 WSDL 服务时,有时会出现错误“底层连接已关闭:预期保持活动状态的连接已被服务器关闭”。 我使用.Net 4.5 WCF 服务...

回答 1 投票 0

如何使用 Maven 通过 Jakarta 生成 WSDL 存根

我需要使用 jakarta 从 .wsdl 文件生成 java 文件。 我正在使用java 20 我使用 jakarta 依赖项和下面的插件并运行 mvn clean install 这是我的 .wsdl 文件的一部分 --- 我需要使用 jakarta 从 .wsdl 文件生成 java 文件。 我正在使用java 20 我使用了 jakarta 依赖项和下面的插件并运行 mvn clean install 这是我的.wsdl文件的一部分 --- <wsdl:binding name="HexingWsServiceSoapBinding" type="tns:HexingWs"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="trans"> <soap:operation soapAction="" style="rpc"/> <wsdl:input name="trans"> <soap:body namespace="http://service.ws.tangdi/" use="literal"/> </wsdl:input> <wsdl:output name="transResponse"> <soap:body namespace="http://service.ws.tangdi/" use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HexingWsService"> <wsdl:port binding="tns:HexingWsServiceSoapBinding" name="HexingWsPort"> <soap:address location="http://-------------------------"/> </wsdl:port> </wsdl:service> <dependency> <groupId>jakarta.xml.ws</groupId> <artifactId>jakarta.xml.ws-api</artifactId> <version>4.0.1</version> </dependency> <plugin> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>4.0.1</version> <executions> <execution> <goals> <goal>wsimport</goal> </goals> </execution> </executions> <configuration> <wsdlDirectory>Development/middle-ware/utility/src/main/resources/</wsdlDirectory> <wsdlFiles> <wsdlFile>hexingws.wsdl</wsdlFile> </wsdlFiles> <packageName>com.omo.robi.ThirdpartyRequest.webservice</packageName> <sourceDestDir> Development/middle-ware/utility/src/main/java/ </sourceDestDir> </configuration> </plugin> java 文件不是用此方法创建的。 我对放置 <sourceDestDir> 和 <packageName> 属性 感到困惑 我想知道我在这里犯了什么错误,还有其他方法可以做到这一点。 有没有办法使用 Apache Axis 来做到这一点 由于我是新手,如果有人可以逐步解释这一点,这对我很有帮助 以下文档和 pom.xml 中的少量修改解决了该问题。 在pom中添加了jakarta依赖。 并按照文档中的步骤操作。 文档链接 希望这会对某人有所帮助:)

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.