如何编译WSDL文件?求指导编译Amadeus Web Services的3个WSDL文件
Hey there! I’ve worked with Amadeus Web Services a few times, so I can walk you through compiling those three WSDL files step by step. The process depends a bit on what programming language you’re using, so I’ll cover the most common ones below:
先做些前置准备
Before diving into compilation, take a quick check:
- Look through each WSDL file for
<import>tags—Amadeus often splits WSDLs into a main service file and dependent schema files. Make sure you know which ones reference others, or if all three are independent. - Save all three WSDL files to the same local folder—this avoids path issues when tools try to resolve dependencies.
Java: Compile with wsimport (JDK built-in tool)
If you’re using Java, the JDK comes with wsimport which handles WSDL-to-Java class generation:
- Open your terminal/command prompt and navigate to the folder where you saved the WSDLs.
- If one WSDL is the main file that imports the other two, run this command (replace
your-main-amadeus.wsdlwith the actual filename):wsimport -keep -verbose your-main-amadeus.wsdl-keepkeeps the generated Java source files (useful for debugging or modifying),-verboseshows detailed logs to catch errors.
- If all three WSDLs are independent, run the command separately for each:
wsimport -keep -verbose amadeus-service-1.wsdl wsimport -keep -verbose amadeus-service-2.wsdl wsimport -keep -verbose amadeus-service-3.wsdl - The tool will generate Java classes organized into packages based on the WSDL’s namespace. Just add these classes to your Java project, and you’re ready to call the Amadeus services.
C#: Compile with svcutil (Visual Studio tool)
For C# projects, use svcutil (included with Visual Studio):
- Open the Visual Studio Developer Command Prompt (or make sure
svcutilis in your system PATH if using a regular command line). - Navigate to your WSDL folder.
- Run this command to generate a single proxy class file for all three WSDLs:
svcutil /language:C# /out:AmadeusServiceClient.cs *.wsdl/outsets the name of the output .cs file,*.wsdltells the tool to process all WSDLs in the folder.
- Add the generated
AmadeusServiceClient.csto your C# project, then make sure you have a reference toSystem.ServiceModel(required for SOAP service calls).
Python: No "compilation" needed—use zeep to load WSDLs directly
Python doesn’t require compiling WSDLs into classes; instead, you can use the zeep library to dynamically consume the services:
- First install zeep via pip:
pip install zeep - In your Python code, load the main WSDL (zeep will automatically pick up dependent WSDLs in the same folder):
from zeep import Client # Load the main Amadeus WSDL client = Client('path/to/your-main-amadeus.wsdl') # Example: Call a service method (replace with actual method name and params) response = client.service.PriceFlight(origin='NYC', destination='LHR', date='2024-12-01') - Use
client.wsdl.dump()to print out all available services, methods, and data types if you need to explore the API structure.
Quick Troubleshooting Tips
- "Cannot find imported WSDL" error: Double-check all WSDLs are in the same folder. If they’re in different locations, you can specify the path to dependent files in the command (e.g.,
wsimport -keep -verbose -wsdllocation ./dependent.wsdl main.wsdlfor Java). - Namespace conflicts: If two WSDLs use the same namespace, generate classes into separate packages (Java: use
-p com.yourcompany.amadeus.service1to set a custom package; C#: use/namespace:YourCompany.Amadeus.Service1). - Amadeus-specific auth: Compilation only generates the client classes—you’ll still need to set up SOAP headers with your Amadeus API credentials (API key, secret, session ID) when making actual calls.
内容的提问来源于stack exchange,提问作者Keyur Padalia
相关产品推荐
相关产品推荐

