Home > Software engineering >  VB sending XML data, the background of a Java program parsing is not!
VB sending XML data, the background of a Java program parsing is not!

Time:10-09

Now in charge of a system, the client through the Java program web server to send XML format file, everything is all right;
Principle is like this, the instrument generates an XML file, and then the client Java software to read, and then use the stream upload,

Now, the client will transform, using VB program to send, a day or two, all sorts of problems are solved, such as HTTP request format but again the backend XML parsing problem:
Unexpected element (uri: "", the local:" INSTRUMENT_ID "). The Expected elements are & lt; {} CHECK_RECORD & gt; , & lt; {} sample> , & lt; {} samples>

Look to find problems, through the httpwatch tools such as check the Java and VB post data found that content is same, can not find out what's the difference between full,
Hexadecimal data, then use winhex saw that there are a number of places, but the hexadecimal data don't quite understand,,,,

About solving ideas, should not be on the background of Java programs do adjustment, because the client use Java programs or still can normal to send,

Which master had similar experience, please do me a favor!
The following is a Java code:
 String webserivceURL=ClientConfigurationUtil. GetValue (WEBSERVICE_URL); 
String dataFormat=ClientConfigurationUtil. GetValue (DATA_FORMAT);
Logger. The debug (" webserivceURL="+ webserivceURL);
The Client Client=Client. The create ();
That WebResource that WebResource=client. The resource (webserivceURL);

FormDataMultiPart FormDataMultiPart=new FormDataMultiPart ();
FormDataMultiPart. BodyPart (new FileDataBodyPart (" file ", dataFile, MediaType. APPLICATION_OCTET_STREAM_TYPE));
FormDataMultiPart. Field (DATA_FORMAT, dataFormat);
ClientResponse response.=that webResource type (MediaType. MULTIPART_FORM_DATA_TYPE). Post (ClientResponse class, formDataMultiPart);

FormDataMultiPart. Close ();


The following is a VB code:
 Private Sub pvPostFile (sUrl As String, sFileName As String, sPath As String, Optional ByVal bAsync As Boolean) 
Const STR_BOUNDARY As String="3 fbd04f5 - b9 b1ed - 4060-99 - fca7ff59c113"
Dim the nFile As Integer
Dim baBuffer () As Byte
Dim sPostData As String

'- read the file
The nFile=FreeFile
The Open sPath For Binary Access Read As nFile
If LOF (nFile) & gt; 0 Then
ReDim baBuffer (0 To LOF (nFile) - 1) As Byte
Get the nFile, baBuffer
SPostData=https://bbs.csdn.net/topics/StrConv (baBuffer vbUnicode)

MsgBox sPostData
End the If
Close the nFile
'- prepare body
SPostData="https://bbs.csdn.net/topics/-" & amp; STR_BOUNDARY & amp; VbCrLf & amp; _
"The content-type: application/octet - stream" & amp; VbCrLf & amp; _
"The Content - the Disposition: the form - data; Filename="" "& amp; Mid $(sFileName, InStrRev (sFileName, "") + 1) & amp; "" "; The file name="" "" "& amp; VbCrLf & amp; _
SPostData & amp; VbCrLf & amp; _
"--" & amp; STR_BOUNDARY & amp; VbCrLf & amp; _
"The content-type: text/plain" & amp; VbCrLf & amp; _
"The Content - the Disposition: the form - data; DataFormat name="" "" "& amp; VbCrLf & amp; VbCrLf & amp; _
"Hk" & amp; VbCrLf & amp; _
"--" & amp; STR_BOUNDARY & amp; "--"

'- post


With CreateObject (" Microsoft. XMLHTTP ")
. Open the "POST", sUrl, bAsync
"SetRequestHeader content-type," "multipart/form - data; A boundary="& amp; STR_BOUNDARY
. Send pvToByteArray (sPostData)

End With

MsgBox "sent"


Help!!!!!!
  • Related