首页 > 解决方案 > 肥皂信封格式无效

问题描述

我正在尝试向此 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>

但这给了我一个无效的格式错误。

我应该如何确定正确的信封格式?

标签: xmlsoapwsdl

解决方案


你是对的,进一步的解决方案:

<?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 --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>'

和响应,在这种情况下是指用户 ID

<?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>

推荐阅读