首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将文件发送到受保护的SOAP web服务

将文件发送到受保护的SOAP web服务
EN

Stack Overflow用户
提问于 2014-03-27 13:18:31
回答 1查看 657关注 0票数 1

我需要编写一个调用SOAP web服务的客户端。我得到了wsdl和一个SOAP request。它是一个安全的web服务,并将一个文件作为附件传递给该服务。我已经使用SOAP UI对其进行了测试,但需要编写一个Java程序来调用该服务。

下面是wsdl

代码语言:javascript
复制
<definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/integration/b2b" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="WS_VT_SECURED_INBOUND" targetNamespace="http://xmlns.oracle.com/integration/b2b">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/integration/b2b">
<element name="TransportFileRequest">
<complexType>
<sequence>
<element minOccurs="1" name="FileName" type="string"/>
<element minOccurs="1" name="FileType" type="string"/>
<element maxOccurs="1" minOccurs="1" name="messageID" type="string"/>
<element maxOccurs="1" minOccurs="1" name="senderID" type="string"/>
<element maxOccurs="1" minOccurs="1" name="checksum" type="string"/>
<element maxOccurs="1" minOccurs="1" name="timestamp" type="string"/>
<element maxOccurs="1" minOccurs="1" name="transportVersion" type="string"/>
<element maxOccurs="1" minOccurs="1" name="payload" type="anyType"/>
</sequence>
</complexType>
</element>
<element name="TransportFileResponse">
<complexType>
<sequence>
<element maxOccurs="1" minOccurs="1" name="Status" type="string"/>
<element maxOccurs="unbounded" minOccurs="0" name="ErrorMessage" type="string"/>
</sequence>
</complexType>
</element>
<element name="error" type="string"/>
</schema>
</types>
<message name="TransportFileResponseMessage">
<part name="FileTransportResponse" element="tns:TransportFileResponse"></part>
</message>
<message name="faultMessage">
<part name="faultMessage" element="tns:error"></part>
</message>
<message name="TransportFileRequestMessage">
<part name="FileTransportRequest" element="tns:TransportFileRequest"></part>
</message>
<portType name="TransportFilePort">
<operation name="sendFile">
<input message="tns:TransportFileRequestMessage"></input>
<output message="tns:TransportFileResponseMessage"></output>
<fault name="faultMessage" message="tns:faultMessage"></fault>
</operation>
</portType>
<binding name="TransportFilePortBinding" type="tns:TransportFilePort">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sendFile">
<soap:operation soapAction="sendFile" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="faultMessage">
<soap:fault name="faultMessage" use="literal"/>
</fault>
</operation>
</binding>
<service name="receiveFile_WS_VT_SECURED_INBOUND">
<port name="TransportFilePort_pt" binding="tns:TransportFilePortBinding">
<soap:address location="https://hostname:9443/wsx/services/receiveFile_WS_VT_SECURED_INBOUND"/>
</port>
</service>
</definitions>

这是SOAP请求,如下所示

代码语言:javascript
复制
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:b2b="http://xmlns.oracle.com/integration/b2b">
   <soapenv:Header/>
   <soapenv:Body>
      <b2b:TransportFileRequest>
          <b2b:FileName>120_VERMONT_ACH_Sanity11march1.dat</b2b:FileName>
         <b2b:FileType>120</b2b:FileType>
         <b2b:MessageID>3454</b2b:MessageID>
         <b2b:SenderID>ekrjekrj</b2b:SenderID>
         <b2b:checksum>b2ee8af554ab6933085d341b71765bc8</b2b:checksum>
         <b2b:timestamp>3434</b2b:timestamp>
         <b2b:transportServiceVersion>4343</b2b:transportServiceVersion>
         <b2b:payload>120_VERMONT_ACH_Sanity11march1.dat</b2b:payload>
      </b2b:TransportFileRequest>
   </soapenv:Body>
</soapenv:Envelope>

在上面的代码中,文件附件是

代码语言:javascript
复制
<b2b:payload>120_VERMONT_ACH_Sanity11march1.dat</b2b:payload>

我知道有多种方法可以做到这一点,比如使用apache http client库或其他任何方法。但是我从来没有使用过Web服务,所以对它知之甚少。尽管我已经开始使用apache http客户端,但是我不能这样做。对于apache问题,我在Sending file to secured SOAP web service using apache http client上发布了一个问题,但到目前为止还没有提供解决方案。没有强制要求必须使用apache http客户端来实现相同的功能。

请让我知道我该怎么做?

EN

回答 1

Stack Overflow用户

发布于 2014-03-27 15:24:27

使用符合JAX-WS的框架,如AxisCXF,并遵循自顶向下的方法。

这些框架提供的工具将帮助您从WSDL开始生成适当的Java客户机类。

如果你想使用超文本传输协议客户端,你必须自己处理SOAP信封,使用java.xml.soap中的类。请参阅SOAPMessage

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

https://stackoverflow.com/questions/22678871

复制
相关文章

相似问题

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