我必须通过网络服务上传文件。 Web服务支持MTOM。因为文档可能非常大,我想在流中上传文档。 问题是Visual Studio将数据的属性deserailize为字节数组(byte [])。所以我必须在上传之前将整个文档加载到内存中。
如何使用Stream属性对wsdl进行反序列化? 如果不可能wsdl看起来像.net那么deserialice它是否正确?
WSDL看起来像:
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://gen.ws.abcd.com" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://gen.ws.abcd.com">
<wsdl:documentation>
TestWService
</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/Message" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/Message">
<xs:simpleType name="StreamBody">
<xs:restriction base="xs:base64Binary"/>
</xs:simpleType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<xs:import namespace="http://schemas.microsoft.com/Message"/>
<xs:element name="MTomDataType">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q1="http://schemas.microsoft.com/Message" name="Data" type="q1:StreamBody"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="StringValue" nillable="true" type="xs:string"/>
</xs:schema>
<xsd:schema xmlns="http://gen.ws.abcd.com" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://gen.ws.abcd.com">
<xsd:complexType name="TImportDocumentImport">
<xsd:sequence>
<xsd:element name="master_filename" minOccurs="0" type="xsd:string"/>
<xsd:element name="temporary_filename" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_number" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_type_long" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_type_short" minOccurs="0" type="xsd:string"/>
<xsd:element name="var_number" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_status" minOccurs="0" type="xsd:string"/>
<xsd:element name="user" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_filename" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_extension" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_directory" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_text_4" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_text_3" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_text_2" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_text_1" minOccurs="0" type="xsd:string"/>
<xsd:element name="holdfile_user" minOccurs="0" type="xsd:string"/>
<xsd:element name="holdfile_group" minOccurs="0" type="xsd:string"/>
<xsd:element name="holdfile_date" minOccurs="0" type="xsd:string"/>
<xsd:element name="holdfile_notice" minOccurs="0" type="xsd:string"/>
<xsd:element name="holdfile_date_remember" minOccurs="0" type="xsd:string"/>
<xsd:element name="holdfile_date_acknowledge_until" minOccurs="0" type="xsd:string"/>
<xsd:element name="book_attribute" minOccurs="0" type="xsd:string"/>
<xsd:element name="reserved_doc_id_header" minOccurs="0" type="xsd:string"/>
<xsd:element name="reserved_doc_id_suffix" minOccurs="0" type="xsd:string"/>
<xsd:element name="transfer_synchron" minOccurs="0" type="xsd:string"/>
<xsd:element name="reject_duplicates" minOccurs="0" type="xsd:string"/>
<xsd:element name="import_hash" minOccurs="0" type="xsd:string"/>
<xsd:element name="asynchronous" minOccurs="0" type="xsd:string"/>
<xsd:element name="signatures_required" minOccurs="0" type="xsd:string"/>
<xsd:element name="batch_alteration_number" minOccurs="0" type="xsd:string"/>
<xsd:element name="color_code" minOccurs="0" type="xsd:string"/>
<xsd:element name="check_hash" minOccurs="0" type="xsd:string"/>
<xsd:element name="import_date" minOccurs="0" type="xsd:string"/>
<xsd:element name="iso" minOccurs="0" type="xsd:string"/>
<xsd:element name="doc_fields" type="TDocFields" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TImportDocumentExport">
<xsd:sequence>
<xsd:element name="doc_id" minOccurs="0" type="xsd:string"/>
<xsd:element name="time_stamp" minOccurs="0" type="xsd:string"/>
<xsd:element name="transfer_error" minOccurs="0" type="xsd:string"/>
<xsd:element name="field_no_with_error" minOccurs="0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ImportDocumentRequest">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="TTestRequest">
<xsd:sequence>
<xsd:element name="import" type="TImportDocumentImport" />
<xsd:element name="bytes" minOccurs="0" maxOccurs="1" type="xsd:base64Binary" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmime:expectedContentTypes="application/octet-stream" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="ImportDocumentResponse">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="TTestResponse">
<xsd:sequence>
<xsd:element name="export" minOccurs="0" maxOccurs="1" type="TImportDocumentExport" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ImportDocumentRequest">
<wsdl:part name="in" element="tns:ImportDocumentRequest"/>
</wsdl:message>
<wsdl:message name="ImportDocumentResponse">
<wsdl:part name="out" element="tns:ImportDocumentResponse"/>
</wsdl:message>
<wsdl:portType name="TestWServicePortType">
<wsdl:operation name="ImportDocument">
<wsdl:input message="tns:ImportDocumentRequest" wsaw:Action="ws.abcd.com/ImportDocument"/>
<wsdl:output message="tns:ImportDocumentResponse" wsaw:Action="ws.abcd.com/TestWS/ImportDocumentResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TestWSbinding" type="tns:TestWServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="ImportDocument">
<soap:operation soapAction="ws.abcd.com/ImportDocument" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TestWService">
<wsdl:port name="TestWSPort" binding="tns:TestWSbinding">
<soap:address location="http://Testserver:8081/ws22/services/TestWServiceGen"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
要反序列化为Stream的属性位于以下行:
<xsd:element name="bytes" minOccurs="0" maxOccurs="1" type="xsd:base64Binary" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmime:expectedContentTypes="application/octet-stream" />