Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trang này cung cấp thông tin về các tiêu đề của yêu cầu SOAP XML bắt buộc và các tiêu đề được trả về trong phản hồi.
Tiêu đề yêu cầu bắt buộc
Tất cả lệnh gọi API SOAP phải có phần tử <RequestHeader> trong tiêu đề; phần tử này được xác định trong tất cả WSDL dịch vụ. Thư viện ứng dụng cung cấp các phương thức để thêm tiêu đề này cho bạn, sử dụng các giá trị mà bạn cung cấp. Sau đây là nội dung mô tả tất cả các phần tử của <RequestHeader>:
Phần tử
Mô tả
<networkCode>
Mã mạng của mạng đang được định địa chỉ. Bạn phải cung cấp mã mạng khi thực hiện tất cả yêu cầu, ngoại trừ NetworkService.getAllNetworks() và NetworkService.makeTestNetwork().
Hãy nhớ chỉ sử dụng mã mạng có sẵn cho thông tin đăng nhập vào tài khoản của bạn. Bạn có thể tìm thấy mã này trên trang web Google Ad Manager cho tài khoản của mình, trên trang Quản trị > Cài đặt mạng bên cạnh "Mã mạng".
<applicationName>
Tên chuỗi tuỳ ý xác định ứng dụng của bạn. Thông tin này sẽ xuất hiện trong tệp nhật ký của Google. Ví dụ: "Khoảng không quảng cáo của tôi
Ứng dụng" hoặc "App_1".
Lưu ý: Mọi yêu cầu mà ứng dụng của bạn gửi tới API Ad Manager đều phải bao gồm mã truy cập OAuth2. Truyền mã thông báo vào tiêu đề HTTP dưới dạng: Authorization: Bearer YOUR_ACCESS_TOKEN.
Yêu cầu mẫu
Mã sau đây là ví dụ về lệnh gọi yêu cầu SOAP đến getAdUnitsByStatement() tìm kiếm AdUnit gốc.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-21 UTC."],[[["\u003cp\u003eThis page outlines the required and returned SOAP XML headers when interacting with the Google Ad Manager API.\u003c/p\u003e\n"],["\u003cp\u003eAll API requests require a \u003ccode\u003eRequestHeader\u003c/code\u003e with \u003ccode\u003enetworkCode\u003c/code\u003e and \u003ccode\u003eapplicationName\u003c/code\u003e, along with an OAuth2 access token in the HTTP header.\u003c/p\u003e\n"],["\u003cp\u003eResponses from the API include a \u003ccode\u003eResponseHeader\u003c/code\u003e containing \u003ccode\u003erequestId\u003c/code\u003e and \u003ccode\u003eresponseTime\u003c/code\u003e for tracking and support purposes.\u003c/p\u003e\n"],["\u003cp\u003eThe API utilizes a document/literal wrapped style for SOAP communication.\u003c/p\u003e\n"]]],["SOAP API calls require a `\u003cRequestHeader\u003e` with a `\u003cnetworkCode\u003e` (except for specific network service requests) and an `\u003capplicationName\u003e`. Each request also needs an OAuth2 access token in the HTTP header. Example SOAP requests are given. Responses include `\u003crequestId\u003e` and `\u003cresponseTime\u003e` headers, which should be logged for troubleshooting. The API uses document/literal wrapped style SOAP. Example response code is given showing the header structure.\n"],null,["# SOAP XML Request and Response Headers\n\nThis page provides information on the required SOAP XML request headers, and the headers that are returned in response.\n| **Note:** The API uses document/literal wrapped style SOAP, not RPC/encoded style.\n\nRequired Request Headers\n------------------------\n\nAll API SOAP calls must have a `\u003cRequestHeader\u003e` element in the header; this element is defined in all the service WSDLs. The [client libraries](/ad-manager/api/clients) provide\nmethods to add this header for you, using the values that you supply. Here is a description of all the elements of `\u003cRequestHeader\u003e`:\n\n| Element | Description |\n|:--------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `\u003cnetworkCode\u003e` | The network code of the network being addressed. Network codes are required when making all requests except `NetworkService.getAllNetworks()` and `NetworkService.makeTestNetwork()`. Be sure that you only use a network code available to your account login. You can find the code on the Google Ad Manager website for your account, on the Admin \\\u003e Network Settings page next to \"Network code\". |\n| `\u003capplicationName\u003e` | An arbitrary string name identifying your application. This will be shown in Google's log files. For example: \"My Inventory Application\" or \"App_1\". |\n\n**Note:** Every request your application sends to the Ad Manager API must include an OAuth2 access token. Pass the token in the HTTP header as: `Authorization: Bearer YOUR_ACCESS_TOKEN`.\n\n**Example Request**\n\nThe following code is an example of a SOAP request call to `getAdUnitsByStatement()` looking for the root `AdUnit`. \n\n```world-of-warcraft-toc\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003csoapenv:Envelope\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\u003e\n \u003csoapenv:Header\u003e\n \u003cns1:RequestHeader\n soapenv:actor=\"http://schemas.xmlsoap.org/soap/actor/next\"\n soapenv:mustUnderstand=\"0\"\n xmlns:ns1=\"https://www.google.com/apis/ads/publisher/v202508\"\u003e\n \u003cns1:networkCode\u003e123456\u003c/ns1:networkCode\u003e\n \u003cns1:applicationName\u003eDfpApi-Java-2.1.0-dfp_test\u003c/ns1:applicationName\u003e\n \u003c/ns1:RequestHeader\u003e\n \u003c/soapenv:Header\u003e\n \u003csoapenv:Body\u003e\n \u003cgetAdUnitsByStatement xmlns=\"https://www.google.com/apis/ads/publisher/v202508\"\u003e\n \u003cfilterStatement\u003e\n \u003cquery\u003eWHERE parentId IS NULL LIMIT 500\u003c/query\u003e\n \u003c/filterStatement\u003e\n \u003c/getAdUnitsByStatement\u003e\n \u003c/soapenv:Body\u003e\n\u003c/soapenv:Envelope\u003e\n```\n\n**Note:** If your SOAP request causes an `Unmarshalling error`, see [Common Errors](/ad-manager/api/troubleshooting#Unmarshalling) for troubleshooting tips.\n\nResponse Headers\n----------------\n\nAll responses returned from the API include the following header elements. As\na best practice, we recommend that you log these values.\n\n| Element | Description |\n|:---------------------|:--------------------------------------------------------------------------------------------------------------------------------------|\n| **\u003crequestId**`\u003e` | Uniquely identifies this request. If you have any support issues, sending us this ID will enable us to find your request more easily. |\n| **`\u003cresponseTime\u003e`** | Elapsed time between the web service receiving the request and sending the response. |\n\n**Example Response**\n\nThe following code shows an example of a SOAP response for the previous request. \n\n```actionscript-3\n\u003csoap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\u003e\n \u003csoap:Header\u003e\n \u003cResponseHeader xmlns=\"https://www.google.com/apis/ads/publisher/v202508\"\u003e\n \u003crequestId\u003exxxxxxxxxxxxxxxxxxxx\u003c/requestId\u003e\n \u003cresponseTime\u003e1063\u003c/responseTime\u003e\n \u003c/ResponseHeader\u003e\n \u003c/soap:Header\u003e\n \u003csoap:Body\u003e\n \u003cgetAdUnitsByStatementResponse xmlns=\"https://www.google.com/apis/ads/publisher/v202508\"\u003e\n \u003crval\u003e\n \u003ctotalResultSetSize\u003e1\u003c/totalResultSetSize\u003e\n \u003cstartIndex\u003e0\u003c/startIndex\u003e\n \u003cresults\u003e\n \u003cid\u003e2372\u003c/id\u003e\n \u003cname\u003eRootAdUnit\u003c/name\u003e\n \u003cdescription\u003e\u003c/description\u003e\n \u003ctargetWindow\u003eTOP\u003c/targetWindow\u003e\n \u003cstatus\u003eACTIVE\u003c/status\u003e\n \u003cadUnitCode\u003e1002372\u003c/adUnitCode\u003e\n \u003cinheritedAdSenseSettings\u003e\n \u003cvalue\u003e\n \u003cadSenseEnabled\u003etrue\u003c/adSenseEnabled\u003e\n \u003cborderColor\u003eFFFFFF\u003c/borderColor\u003e\n \u003ctitleColor\u003e0000FF\u003c/titleColor\u003e\n \u003cbackgroundColor\u003eFFFFFF\u003c/backgroundColor\u003e\n \u003ctextColor\u003e000000\u003c/textColor\u003e\n \u003curlColor\u003e008000\u003c/urlColor\u003e\n \u003cadType\u003eTEXT_AND_IMAGE\u003c/adType\u003e\n \u003cborderStyle\u003eDEFAULT\u003c/borderStyle\u003e\n \u003cfontFamily\u003eDEFAULT\u003c/fontFamily\u003e\n \u003cfontSize\u003eDEFAULT\u003c/fontSize\u003e\n \u003c/value\u003e\n \u003c/inheritedAdSenseSettings\u003e\n \u003c/results\u003e\n \u003c/rval\u003e\n \u003c/getAdUnitsByStatementResponse\u003e\n \u003c/soap:Body\u003e\n\u003c/soap:Envelope\u003e\n```"]]