Reputation: 95
My company posts invoices to both Ariba and Oracle Supplier Networks via HTTP POST. We've had an issue where we haven't been able to determine whether it comes from its settings or code.
Below is the code:
Public Function SendMime(pFiles As List(Of String)) As String
'just use the text send option in HTTP connection
If pFiles.Count = 1 And pFiles.Item(0).EndsWith(".xml") Then
Return Send(My.Computer.FileSystem.ReadAllText(pFiles(0)))
End If
Dim Request As Net.HttpWebRequest
Request = DirectCast(Net.WebRequest.Create(GetFirstURL()), Net.HttpWebRequest)
Request.ContentType = "multipart/related;boundary=" & OuterBoundary & ";type=""text/xml"";start=""<" & _CID & ".1>"""
Request.Method = "Post"
Request.KeepAlive = True
WriteRequest(Request, pFiles)
Dim Response As Net.WebResponse
Try
Response = Request.GetResponse()
Dim ResponseStream As Stream = Response.GetResponseStream()
Dim ResponseReader As New StreamReader(ResponseStream)
Return ResponseReader.ReadToEnd()
Catch ex As System.Exception
Return "error: " & ex.Message
End Try
End Function
Private Sub WriteRequest(pRequest As Net.WebRequest, pFiles As List(Of String))
Dim PartCount As Integer = 1
_RequestStream = pRequest.GetRequestStream()
_tempStream = New FileStream("C:\lastMIMEsent.txt", FileMode.Create)
For Each File As String In pFiles
WriteBoundary(OuterBoundary)
If File.ToLower.EndsWith(".xml") Then
GetXMLPart(File, PartCount)
ElseIf File.ToLower.EndsWith(".pdf") Then
GetPDFPart(File, PartCount)
End If
PartCount += 1
Next
WriteTrailer(OuterBoundary)
_RequestStream.Close()
_tempStream.Flush()
_tempStream.Close()
End Sub
The send function is similar to the SendMime function, but with no attachments (cXML only). This code is shared between a Windows Service and a basic GUI test program.
edit: The error I get is:
Unable to connect to host
Where things get weird:
I've been trying to figure this out for a couple weeks, experimenting with different adjustments, and at this point, both I and the server team are out of ideas. Any advice, whether its red flags in my code or just known windows server issues, would be greatly appreciated.
Upvotes: 0
Views: 52