Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Ta strona zawiera informacje o wymaganych nagłówkach żądania XML SOAP oraz nagłówkach zwracanych w odpowiedzi.
Wymagane nagłówki żądania
Wszystkie wywołania SOAP interfejsu API muszą zawierać w nagłówku element <RequestHeader>. ten element jest zdefiniowany we wszystkich plikach WSDL usługi. Biblioteki klienta udostępniają
aby dodać ten nagłówek za Ciebie, używając podanych przez Ciebie wartości. Oto opis wszystkich elementów <RequestHeader>:
Element
Opis
<networkCode>
Kod sieci, do której adres jest adresowany. W przypadku wszystkich żądań oprócz NetworkService.getAllNetworks() i NetworkService.makeTestNetwork() wymagane są kody sieci.
Upewnij się, że używasz tylko kodu sieci dostępnego dla logowania na Twoje konto. Kod możesz znaleźć w witrynie Google Ad Managera swojego konta, w sekcji Administracja > Ustawienia sieci obok pozycji „Kod sieci”.
<applicationName>
Nazwa dowolnego ciągu znaków identyfikująca aplikację. Będzie ona widoczna w plikach dzienników Google. Na przykład: „Moje zasoby reklamowe
Aplikacja lub „App_1”.
Uwaga: każde żądanie wysyłane przez aplikację do interfejsu Ad Manager API musi zawierać token dostępu OAuth 2. Przekaż token w nagłówku HTTP w ten sposób: Authorization: Bearer YOUR_ACCESS_TOKEN.
Przykładowe żądanie
Ten kod jest przykładowym wywołaniem żądania SOAP pod adresem getAdUnitsByStatement(), które wyszukuje katalog główny AdUnit.
Uwaga: jeśli żądanie SOAP powoduje błąd Unmarshalling error, przeczytaj artykuł Typowe błędy, w którym znajdziesz wskazówki dotyczące rozwiązywania problemów.
Nagłówki odpowiedzi
Wszystkie odpowiedzi zwracane przez interfejs API zawierają poniższe elementy nagłówka. Zalecamy, aby rejestrować te wartości.
Element
Opis
<requestId>
Jednoznacznie identyfikuje to żądanie. W przypadku jakichkolwiek problemów z zespołem pomocy,
Identyfikator pozwoli nam łatwiej znaleźć Twoją prośbę.
<responseTime>
Czas między otrzymaniem żądania przez usługę internetową a wysłaniem odpowiedzi.
Przykładowa odpowiedź
Poniższy kod zawiera przykładową odpowiedź SOAP dla poprzedniego żądania.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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```"]]