1

SOAP のみの一連のサービスをサポートする必要がありますが、既存のクライアントがほとんどまたはまったく変更せずにこれらのサービスを利用できるようにサービスを定義するのに苦労しています。私が苦労している問題は、1. POST 値を正しく取得すること、2. SOAPAction、3. データ型を含めること、4. すべての子データ メンバーを含めることです。

店舗を検索する次の単純なサービスについて考えてみましょう。

- - リクエスト - -

POST /services-1.0/Store.asmx
SOAPAction: http://example.com/Services/LookupStores
Content-Type: text/xml; charset=utf-8
Content-Length: string
Host: string

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <LookupStores xmlns="http://example.com/Services">
      <AuthenticationID>string</AuthenticationID>
      <NameMatch>string</NameMatch>
    </LookupStores>
  </soap:Body>
</soap:Envelope>

- - 応答 - - -

HTTP/1.0 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: string

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <LookupStoresResponse xmlns="http://example.com/Services">
      <LookupStoresResult>
        <StoreList>
          <StoreData>
            <Number>string</Number>
            <Name>string</Name>
          </StoreData>
          <StoreData>
            <Number>string</Number>
            <Name>string</Name>
          </StoreData>
        </StoreList>
        <ResponseCode>string</ResponseCode>
        <ResponseMessage>string</ResponseMessage>
        <ExtendedResponseMessage>string</ExtendedResponseMessage>
      </LookupStoresResult>
    </LookupStoresResponse>
  </soap:Body>
</soap:Envelope>

うまくいけばそれを模倣するサービスコード:

public class Store : Service
{
    public LookupStoresResponse Post(LookupStores request)
    {
        return new LookupStoresResponse();
    }
}

[DataContract(Namespace="http://example.com/Services")]
public class LookupStores
{
    [DataMember]
    string AuthenticationID { get { return ""; } set { } }
    [DataMember]
    string NameMatch;
}

 [DataContract]
public class LookupStoresResponse
{
    [DataMember]
    List<StoreData> LookupStoresResult;
}

[DataContract]
public class LookupStoresResult
{
    [DataMember]
    List<StoreData> StoreList;
}

[DataContract]
public class StoreData
{
    [DataMember]
    string Number;
    [DataMember]
    string Name;
}

収量:

POST /soap11 HTTP/1.1 
Host: localhost 
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: LookupStores

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>

<LookupStores xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.com/Services">
  <AuthenticationID />
  <NameMatch i:nil="true" />
</LookupStores>

    </soap:Body>
</soap:Envelope>


HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>

<LookupStoresResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/EagleServices.Services">
  <LookupStoresResult i:nil="true" />
</LookupStoresResponse>

    </soap:Body>
</soap:Envelope>
4

0 に答える 0