0
当我们发送一个请求时,我们得到一个400 /错误的请求。请在下面找到我们的代码。使用vbscript发送xmlhttp到wcf时,得到一个400错误的请求
Public Sub test123()
URL = "http://dev1.xxxxx.employer/employer/v02/Employer.svc"
Dim requestDoc
Set requestDoc = CreateObject("MSXML2.DOMDocument.3.0")
Dim root
Set root = requestDoc.createNode(1, "Envelope", "http://schemas.xmlsoap.org/soap/envelope/")
requestDoc.appendChild root
Dim nodeBody
Set nodeBody = requestDoc.createNode(1, "Body", "http://schemas.xmlsoap.org/soap/envelope/")
root.appendChild nodeBody
Dim nodeOp
Set nodeOp = requestDoc.createNode(1, "Register", "http://xxxxx.com/Employer/Contracts/v2")
nodeBody.appendChild nodeOp
Dim nodeRequest
Set nodeRequest = requestDoc.createNode(1, "request", "http://xxxxx.com/Employer/Contracts/v2")
'content of the request will vary depending on the WCF Service.'
' This one takes just a plain string. '
Dim sv_strTempxml As Variant
sv_strTempxml1 = "<CreateProspectRequest xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">" _
& "<Employer><PartyDisplayName>0707 NS2 DEV1 KRISH 001</PartyDisplayName><PreferredLanguageIdentifier xsi:nil=""true"" />" _
& "<PartyIdentifier xsi:nil=""true"" /><PartyAddresses><PartyAddressStructure><BeginTimeStamp xsi:nil=""true"" /><CityName>Alexander City</CityName>" _
& "<CountryCode>US</CountryCode><EndTimeStamp xsi:nil=""true"" /><FirstLineAddress>111 Main Street</FirstLineAddress><PostalCode>35010</PostalCode>" _
& "<SecondJurisdictionCode>AL</SecondJurisdictionCode><SecondJurisdictionTypeCode>ST</SecondJurisdictionTypeCode><SecondLineAddress>PL</SecondLineAddress><AddressIdentifier xsi:nil=""true"" />" _
& "<PartyIdentifier xsi:nil=""true"" /><AddressUsageIdentifier>100000</AddressUsageIdentifier><SecondJurisdiction>1</SecondJurisdiction><ChangeTypeCode xsi:nil=""true"" />" _
& "</PartyAddressStructure></PartyAddresses><PreferredLanguage>100</PreferredLanguage><ChangeTypeCode xsi:nil=""true"" /><PartyTypeIdentifier xsi:nil=""true"" />" _
& "<EstablishedDate xsi:nil=""true"" /><OrganizationTypeIdentifier>100018</OrganizationTypeIdentifier><OrganizationNames><OrganizationNameStructure>" _
& "<NameEndTimestamp xsi:nil=""true"" /><NameStartTimestamp xsi:nil=""true"" /><OrganizationPartyName>0707 NS2 DEV1 KRISH 001</OrganizationPartyName><NameTypeIdentifier>1</NameTypeIdentifier>" _
& "<PartyIdentifier xsi:nil=""true"" /><ChangeTypeCode xsi:nil=""true"" /></OrganizationNameStructure></OrganizationNames><ProspectReceivedDate xsi:nil=""true"" />" _
& "<RatingGroupIdentifier xsi:nil=""true"" /></Employer><AffiliationCode>UUS</AffiliationCode></CreateProspectRequest>"
nodeRequest.Text = sv_strTempxml1
nodeOp.appendChild nodeRequest
Set nodeRequest = Nothing
Set nodeOp = Nothing
Set nodeBody = Nothing
Set root = Nothing
'MsgBox "sending request " & vbCrLf & requestDoc.XML
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.3.0")
' set the proxy as necessary and desired '
'xmlhttp.setProxy 2, "http://localhost:8888"
xmlhttp.Open "POST", URL, False
' set SOAPAction as appropriate for the operation '
xmlhttp.setRequestHeader "SOAPAction", "http://xxxxx.com/Employer/Contracts/v2/Employer/CreateProspect"
xmlhttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
xmlhttp.send requestDoc.XML
' vbCrLf & "Raw XML response:" & vbCrLf
MsgBox xmlhttp.responseXML.XML
End Sub
是存在的,我们已经错过了
Santhosh
其使用基本的HTTP绑定,当我改变内容类型为text/xml我得到一个错误,指出内容类型应该是“应用/ soap + xml“ – user437792 2010-09-02 13:32:08
嗯,这很奇怪,这是我以前用过的。我更新了一些更详细的答案 – 2010-09-02 14:25:14