2010-12-02 5 views

답변

2

http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl 위에서 주어진 URL 에 대해 svcutil.exe를 사용하여 프록시를 만든 다음 GetBookByISBN 방법입니다. AmazonBook은 자신 만의 독창적 인 DTO입니다.

public static AmazonBook GetBookByISBN(string ISBN) 
    { 
     WebConfigHelper wch = new WebConfigHelper("AWSSettings"); 
     AmazonBook book = null; 
     string AWSAccessKeyId = wch["AccessKey"]; 
     string AssociateTag = wch["AssociateTag"]; 
     string AWSSecKey = wch["SecretKey"]; 

     BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); 
     binding.MaxReceivedMessageSize = int.MaxValue; 

     AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
      binding, 
      new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); 

     // add authentication to the ECS client 
     client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(AWSAccessKeyId, AWSSecKey)); 


     ItemSearchRequest request = new ItemSearchRequest(); 
     request.SearchIndex = "Books"; 
     request.Power = "ISBN:" + ISBN.Trim(); 
     request.ResponseGroup = new string[] { "Large" }; 
     request.Sort = "salesrank"; 

     ItemSearchRequest[] requests = new ItemSearchRequest[] { request }; 

     ItemSearch itemSearch = new ItemSearch(); 
     itemSearch.AWSAccessKeyId = AWSAccessKeyId; 
     itemSearch.AssociateTag = AssociateTag; 
     itemSearch.Request = requests; 


     try 
     { 
      ItemSearchResponse response = client.ItemSearch(itemSearch); 
      Items info = response.Items[0]; 
      if (info.Item != null) 
      { 
       Item[] items = info.Item; 
       if (items.Length == 1) 
       { 
        book = new AmazonBook(items[0]); 
       } 
      } 
     } 
     catch (Exception ex) 
     { 
      throw ex; 
     } 
     return book; 


    } 

Reagards

,

+0

이 WCF 서비스 참조는 다음과 같습니다 라이브러리는 또한 .NET 표준 2.0

당신은 asp.net Website 구현 예를 여기

PM> Install-Package Nager.AmazonProductAdvertising 

짧은 예를 찾을 수 있습니다을 지원합니까? SOAP 웹 서비스에 더 관심이 있습니다. –

+0

태그를 연결 하시겠습니까? 액세스 키는 있지만 연관 태그는 볼 수 있습니까? –

+0

어소시에이트 태그는 Amazon을 특정 Amazon 계정에서 Amazon으로 리디렉션 한 Amazon 사용자를 추적하는 데 사용되는 태그입니다. 자세한 정보는 https://forums.aws.amazon.com/thread.jspa?messageID=149729 –

0

당신은 당신이 nuget에 쉽게 설치할 수있는이 라이브러리 Nager.AmazonProductAdvertising을 사용할 수 있습니다.

var authentication = new AmazonAuthentication(); 
authentication.AccessKey = "accesskey"; 
authentication.SecretKey = "secretkey"; 

var wrapper = new AmazonWrapper(authentication, AmazonEndpoint.US); 
//The Lord of the Rings 
var result = wrapper.Lookup("978-0261102385"); 
관련 문제