There is my code:
=> Part of my web.config (c#):
<basicHttpBinding>
<binding name="secureHttpBinding"
maxReceivedMessageSize="2097152" messageEncoding="Mtom"
transferMode="Streamed">
<readerQuotas maxStringContentLength="2097152" maxArrayLength="2097152" />
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
=> Function I want to call (c#):
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)]
ImageData UploadImage(string clientAppKey, string organizationId, string name, byte[] value);
=> My soap I try to send (vb6):
Headers:
objHttpRequest.SetRequestHeader "Content-Type", "multipart/related; type=""application/xop+xml"";start=""<http://tempuri.org/0>"";boundary=""uuid:d2d519f9-a921-436c-95b0-e31576611a01+id=16"";start-info=""text/xml"""
objHttpRequest.SetRequestHeader "SOAPAction", strNameSpace_ & "IFileHostService/" & strAction
objHttpRequest.SetRequestHeader "MIME-Version", "1.0"
Data:
--uuid:d2d519f9-a921-436c-95b0-e31576611a01+id=16
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><UploadImage xmlns="http://tempuri.org/"><clientAppKey>12345</clientAppKey><organizationId>000012</organizationId><name>b8e5cb8c-f82e-450d-a80a-29374640d34200.png</name><value><Include xmlns="http://www.w3.org/2004/08/xop/include" href="cid:http://tempuri.org/1/635630514915728569"/></value></UploadImage></soap:Body></soap:Envelope>
--uuid:d2d519f9-a921-436c-95b0-e31576611a01+id=16
Content-ID: <http://tempuri.org/1/635630514915728569>
Content-Transfer-Encoding: binary
Content-Type: application/octet-stream
[My bytes array??]
--uuid:d2d519f9-a921-436c-95b0-e31576611a01+id=16
There is my problem:
I received my data in c#, but the bytes array I received is not good.
I try many way to send my byte array.
1- I try in base64 but the bytes array in c# is longer than my bytes array in vb6. example: I send a byte array of 40000 in vb6 and got a array of 50000 in c#.
2- I try in string unicode but the array was too short. example: I send StrConv(b(), vbUnicode) and got a array of 8 in c#. UBound(b) = 40000
My question is how I send my byte array in vb6 to get the same array in c#?
Thanks for your time.
Finally, I found a way that it work.
I send my byte array in base64 and convert in c#.
value = Convert.FromBase64String(Encoding.UTF8.GetString(value));
The solution with StrConv(b(), vbUnicode) not working because when c# read my string it stop reading on char 0.