Получение ошибки - тип контента 'text / xml; charset = UTF-8 'не был ожидаемым типом при запросе wcf с использованием сценария xmlhttp by vb - PullRequest
0 голосов
/ 03 сентября 2010

Привет, я новичок в wcf и xmlhttp, я использую скрипт vb для отправки запроса.я получаю следующую ошибку: «Не удается обработать сообщение, поскольку тип содержимого« text / xml; charset = UTF-8 »не соответствует ожидаемому типу« application / soap + xml; charset = utf-8 »."

Пожалуйста, найдите мой код ниже,

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'><Employer><PartyDisplayName>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 ]

2 голосов
/ 03 сентября 2010

Почти каждый раз, когда я получаю сообщение об ошибке

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

Это потому, что сервер возвратил страницу с ошибкой вместо ответа на вызов WCF.ответ, чтобы увидеть, что сообщение об ошибке.

1 голос
/ 03 сентября 2010

Вы уверены, что отправляете SOAP-запрос? Я не вижу мыла: конверт или мыло: элементы тела по вашему запросу. Ваша проблема с типом контента, вероятно, связана с тем, что вы отправляете текст / xml, но сервер ожидает application / soap + xml. Это происходит, когда вы пытаетесь отправить SOAP 1.1 запрос в службу, ожидающую SOAP 1.2.

...