Недопустимый формат конверта soap

#xml #soap #wsdl

#xml #soap #wsdl

Вопрос:

Я пытаюсь создать сообщение для этой службы WSDL:

https://elstestserver.endicia.com/LabelService/EwsLabelService.asmx?wsdl

В документах API приведен этот пример: (https://www.endicia.com/developer/docs/els.html#validateaddressrequest )

 POST /LabelService/EwsLabelService.asmx HTTP/1.1
Host: labelserver.endicia.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "www.envmgr.com/LabelService/ValidateAddress"

<ValidateAddress>
 <ValidateAddressRequest>
    <RequesterID>String</RequesterID>
    <CertifiedIntermediary>
       <AccountID>String</AccountID>
       <PassPhrase>String</PassPhrase>
    </CertifiedIntermediary>
    <Address>
     <Name>String</Name>
       <Company>String</Company>
       <Address1>String</Address1>
       <City>String</City>
       <State>String</State>
    </Address>
 </ValidateAddressRequest>
</ValidateAddress>
  

Но я не могу определить правильный формат для конверта.

Я пытался:

 <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ValidateAddress>
            <ValidateAddressRequest>
                <RequesterID>String</RequesterID>
                <CertifiedIntermediary>
                    <AccountID>String</AccountID>
                    <PassPhrase>String</PassPhrase>
                </CertifiedIntermediary>
                <Address>
                    <Name>String</Name>
                    <Company>String</Company>
                    <Address1>String</Address1>
                    <City>String</City>
                    <State>String</State>
                </Address>
            </ValidateAddressRequest>
        </ValidateAddress>
    </soap:Body>
</soap:Envelope>
  

Но это дает мне ошибку недопустимого формата.

Как я должен определять правильный формат конверта?

Ответ №1:

Вы, верно, дальнейшее решение:

 <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="www.envmgr.com/LabelService">
  <soap:Body>
    <ValidateAddress>
        <ValidateAddressRequest>
            <RequesterID>String</RequesterID>
            <CertifiedIntermediary>
            <AccountID>test</AccountID>
            <PassPhrase>123</PassPhrase>
            </CertifiedIntermediary>
            <Address>
            <Name>String</Name>
            <Company>String</Company>
            <Address1>String</Address1>
            <City>String</City>
            <State>String</State>
            </Address>
        </ValidateAddressRequest>
    </ValidateAddress>
</soap:Body>
</soap:Envelope>
  

Пример запроса Curl

 curl --location --request POST 'https://labelserver.endicia.com/LabelService/EwsLabelService.asmx' 
--header 'SOAPAction: www.envmgr.com/LabelService/ValidateAddress' 
--header 'Content-Type: text/xml' 
--data-raw '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="www.envmgr.com/LabelService">
  <soap:Body>
    <ValidateAddress>
        <ValidateAddressRequest>
            <RequesterID>String</RequesterID>
            <CertifiedIntermediary>
            <AccountID>test</AccountID>
            <PassPhrase>123</PassPhrase>
            </CertifiedIntermediary>
            <Address>
            <Name>String</Name>
            <Company>String</Company>
            <Address1>String</Address1>
            <City>String</City>
            <State>String</State>
            </Address>
        </ValidateAddressRequest>
    </ValidateAddress>
</soap:Body>
</soap:Envelope>'
  

и ответ, который в данном случае ссылается на идентификатор пользователя

 <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <ValidateAddressResponse xmlns="www.envmgr.com/LabelService">
            <ValidateAddressResponse>
                <Status>61501</Status>
                <ErrorMessage>Account ID test is invalid. Error encountered (Log ID: 46531)</ErrorMessage>
                <AddressMatch>false</AddressMatch>
                <CityStateZipOK>false</CityStateZipOK>
                <ResidentialDeliveryIndicator>false</ResidentialDeliveryIndicator>
                <IsPOBox>false</IsPOBox>
            </ValidateAddressResponse>
        </ValidateAddressResponse>
    </soap:Body>
</soap:Envelope>
  

Комментарии:

1. Я предоставил этот заголовок в запросе. Ошибка, которую я получаю, не связана с этим. Ошибка — недопустимый xml.