سؤال

Language: C++/CX & XAML Environment: Visual Studio 2013 on Windows 8.1

I am trying to use the Amazon Product Advertising API in my Windows Store app. I have an Associates account so I am allowed to use this however I'm having problems implementing the .wsdl file after using wsutil.exe to create a .c and .h file for my project.

The .c and .h files both have errors pointing to identifiers that reside inside WebServices.h.

Since the .c and .h files have a combined length of more than 13k lines of code I'll write out steps to reproduce my problem.

-Navigate to http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

-Save the file either in a project fold or on the desktop

-Open up a VS2013 command prompt and navigate to where the file resides

-Type "wsutil /wsdl:AWSECommerceService.wsdl" This produces the .c and .h files that can be used in the project

-Add the .c and .h files to a VC++ Windows Store app project

since the environment language is C++/CX and wsutil gave us a .c file we need to tell the compiler to treat this file as a C++ file otherwise if you try to build like it is it throws an error saying:

Command line error D8048: cannot compile C file '....\New folder\AWSECommerceService.wsdl.c' with the /ZW option

My first attempt at trying to fix this was to remove the /ZW option. This can be done by right clicking the .c file, click properties, under "General" you will will see "yes(/ZW)" which you can change to "no".

after doing this and trying to build it gives this error:

...\awsecommerceservice.wsdl.c : fatal error C1853: 'Debug\SimpleShop.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

That wasn't the correct fix so I went back and added the /ZW option.

Next I decided to tell the compiler to treat the .c file as a .cpp file by adding the /TP option. You can find this by right clicking the .c file, clicking properties, click Advanced, click the drop down box next to "Compile as" and selected /TP.

Now when trying to build the project errors appear in both the .c and .h files for identifiers that reside in the WebServices.h file.

This is where I'm stuck at. I tried to #include "WebServices.h" into the .h file (which is oddly missing it whereas the .c file is not) and this does nothing to remove any of the errors.

I can find nothing about using the Amazon Product Advertising API inside a windows store app on the internet so all of the attempted fixes came from Win7 or WCF forums. The steps I'm trying to follow are from Amazon on they can be found here (focus on step 4):

http://docs.aws.amazon.com/AWSECommerceService/latest/GSG/GettingSetUp.html

these are the errors: 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1037): error C2371: '_RelatedItems::RelatedItemCount' : redefinition; different basic types 1> c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1034) : see declaration of '_RelatedItems::RelatedItemCount' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1576): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1604): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1632): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1660): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1688): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1716): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1744): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1772): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1800): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1828): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(1856): error C2061: syntax error : identifier 'WS_SERVICE_SECURITY_CALLBACK' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(2709): error C2146: syntax error : missing ';' before identifier 'AWSECommerceServiceBinding' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.h(2709): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.c(1159): error C2146: syntax error : missing ';' before identifier 'contractDesc' 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.c(1159): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\scott\desktop\new folder\awsecommerceservice.wsdl.c(6674): fatal error C1903: unable to recover from previous error(s); stopping compilation

هل كانت مفيدة؟

المحلول

There are several things going on here:

  1. You need to include the header pch.h at the top of the generated .c file

  2. This sounds like a genuine error in the generated header. Notice a member defined twice.

    typedef struct _RelatedItems

    {

    enum _Relationship Relationship;
    WCHAR* RelationshipType;
    unsigned __int64 RelatedItemCount;
    unsigned __int64 RelatedItemPageCount;
    unsigned __int64 RelatedItemPage;
    unsigned int RelatedItemCount;
    _Field_size_(RelatedItemCount)struct _RelatedItem* RelatedItem;
    

    } _RelatedItems;

  3. The other errors are because the missing identifiers are actually not available for Windows Store apps. Both WS_SERVICE_SECURITY_CALLBACK and WS_CONTRACT_DESCRIPTION are conditionally defined in the SDK header WebServices.h only for Desktop apps

    "if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top