views:

65

answers:

2

Hi i am new to wcf and xmlhttp, i am using vb script to send the request. i am getting the following error "Cannot process the message because the content type 'text/xml; charset=UTF-8' was not the expected type 'application/soap+xml; charset=utf-8'."

Please find my code below,

g_XMLLink = "http://dev1.xxxxx.employer/employer/v02/Employer.svc"
Set xmlhttp = Nothing
Set xmldom = Nothing '
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
Set xmldom = CreateObject("Microsoft.XMLDOM")

completexml = "<CreateProspectRequest xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'&gt;&lt;Employer&gt;&lt;PartyDisplayName&gt;cbs1a test</PartyDisplayName><PreferredLanguageIdentifier xsi:nil='true' /><PartyIdentifier xsi:nil='true' /><PartyAddresses>" _
& "<PartyAddressStructure><BeginTimeStamp xsi:nil='true' /><CityName>portland</CityName><CountryCode>US</CountryCode><EndTimeStamp xsi:nil='true' /><FirstLineAddress>congress street</FirstLineAddress><PostalCode>04102</PostalCode><SecondJurisdictionCode>ME</SecondJurisdictionCode><SecondJurisdictionTypeCode>ST</SecondJurisdictionTypeCode>" _
& "<SecondLineAddress /><AddressIdentifier xsi:nil='true' /><PartyIdentifier xsi:nil='true' /><AddressUsageIdentifier>100000</AddressUsageIdentifier><SecondJurisdiction>20</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>cbs1a test</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>"

xmlhttp.Open "POST", g_XMLLink, False
xmlhttp.setRequestHeader "ContentType", "text/xml; charset=utf-8"
xmlhttp.setRequestHeader "SoapAction", "http://xxxxx.com/Employer/Contracts/v2/Employer/CreateProspect"


xmldom.loadXML completexml
xmlhttp.send xmldom
MsgBox xmlhttp.responseText
+2  A: 

Almost every time I have got the error

type 'text/xml; charset=UTF-8' was not the expected type 'application/soap+xml; charset=utf-8'."

It has been because the server has returned an error page instead of a response to the WCF call.

You need to log the response to see what the error message is.

Shiraz Bhaiji
+1  A: 

Are you sure you are sending SOAP request? I don't see any soap:Envelope or soap:Body elements in your request. Your content type problem is probably based on fact that you are sending text/xml but the server expects application/soap+xml. This happens when you try to send SOAP 1.1 request to service expecting SOAP 1.2.

Ladislav Mrnka