嗨,我正在尝试编写一个小型VB.net程序,该程序将更新我们oracle CPQ网站上的一些数据。基本上,我使用了CPQ站点中使用的示例XML作为测试(直接在站点上工作(,并将其移植到vb.net程序中。我在第56行得到一个错误500"内部服务器错误"Response=Request.GetResponse((
Dim Request As WebRequest
Dim Response As WebResponse
Dim DataStream As Stream
Dim Reader As StreamReader
Dim SoapByte() As Byte
Dim SoapStr As String
Dim pSuccess As Boolean = True
SoapStr = "<?xml version=""1.0"" encoding=""utf-8""?>"
SoapStr = SoapStr & "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"">"
SoapStr = SoapStr & "<soapenv:Header/>"
SoapStr = SoapStr & "<wsse:Security xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"" xmlns:wsu=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">"
SoapStr = SoapStr & "<wsse:UsernameToken wsu:Id=""UsernameToken-2"">"
SoapStr = SoapStr & "<wsse:Username>username</wsse:Username>"
SoapStr = SoapStr & "<wsse:Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"">password</wsse:Password>"
SoapStr = SoapStr & "</wsse:UsernameToken>"
SoapStr = SoapStr & "</wsse:Security>"
SoapStr = SoapStr & "</soapenv:Header>"
SoapStr = SoapStr & "<soapenv:Body>"
SoapStr = SoapStr & "<bm:modifyParts xmlns:bm=""http://xmlns.oracle.com/cpqcloud/parts"">"
SoapStr = SoapStr & "<bm:Parts>"
SoapStr = SoapStr & "<bm:each_record>"
SoapStr = SoapStr & "<bm:part_number>0000158-01-LIMT-MX-10</bm:part_number>"
SoapStr = SoapStr & "<bm:description>"
SoapStr = SoapStr & "<bm:en>OPER - SOAP Test 1</bm:en>"
SoapStr = SoapStr & "</bm:description>"
SoapStr = SoapStr & "</bm:each_record>"
SoapStr = SoapStr & "</bm:Parts>"
SoapStr = SoapStr & "</bm:modifyParts>"
SoapStr = SoapStr & "</soapenv:Body>"
SoapStr = SoapStr & "</soapenv:Envelope>"
Try
SoapByte = System.Text.Encoding.UTF8.GetBytes(SoapStr)
Request = WebRequest.Create("https://velaninctest.bigmachines.com/v2_0/receiver/parts")
Request.Headers.Add("SOAPAction", "https://velaninctest.bigmachines.com/v2_0/receiver/parts")
Request.ContentType = "text/xml; charset=utf-8"
Request.ContentLength = SoapByte.Length
Request.Method = "POST"
DataStream = Request.GetRequestStream()
DataStream.Write(SoapByte, 0, SoapByte.Length)
DataStream.Close()
Response = Request.GetResponse()
DataStream = Response.GetResponseStream()
Reader = New StreamReader(DataStream)
Dim SD2Request As String = Reader.ReadToEnd()
TextBox1.Text = SD2Request
DataStream.Close()
Reader.Close()
Response.Close()
Catch ex As WebException
MsgBox(ex.ToString())
End Try
不确定我做错了什么。您可以检查可用服务调用的WSDL定义:https://velaninctest.bigmachines.com/v2_0/receiver/
CPQ站点测试SOAP调用的样本
您现在可能已经找到了它,但看起来您在它的内容之前关闭了第12行的"标记。无法与VB.net通话(时间太长(,但CPQ Web服务调用看起来不错。
-Chris