function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dai.odaharadai.odahara 

Metadata API with sessonId of enterprise wsdl login result

Hello, guys. Does anyone succeed in hitting metadata api like create method?
Now I'm trying it but an error saying "INVALID_SESSIN_ID" occurs.

I'm doing like below with java client, but it does not work.
---
Calls login() which is part of the enterprise WSDL and, if the login succeeds:
  • Sets the returned sessionId into the session header for the metadata SOAP binding. This is required for session authentication on subsequent metadata API calls.
  • Resets the endpoint to the returned metadataServerUrl, which is the target of subsequent metadata API calls.

    All client applications that access the metadata API must complete the tasks in this step before attempting any subsequent metadata API calls.

---

does someone have any hint..? my soap message is the followings.

--

<v:Envelope xmlns:i="http://soap.sforce.com/2006/04/metadata"
    xmlns:d="http://www.w3.org/2001/XMLSchema"
    xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:t="http://soap.sforce.com/2006/04/metadata">
    <v:Header>
        <v:SessionHeader n0:mustUnderstand="0"
            n1:ns1="http://soap.sforce.com/2006/04/metadata" xmlns:n0="soapenv"
            xmlns:n1="xmlns">
            <v:sessionId n2:type="xsd:string" xmlns:n2="xsi">
           xxxxx(session id)
            </v:sessionId>
        </v:SessionHeader>
    </v:Header>
    <v:Body>
        <t:create id="o0" c:root="1">
            <metadata n3:type="t:metadata"
                xmlns:n3="http://www.w3.org/2001/XMLSchema-instance">
                <fullName n3:type="d:string">
                    Event.ByMetaDataAPI__c
                </fullName>
                <label n3:type="d:string">ByMetaDataAPI</label>
                <length n3:type="d:int">100</length>
                <type n3:type="d:string">Text</type>
            </metadata>
        </t:create>
    </v:Body>
</v:Envelope>
--

thank you very much,

SuperfellSuperfell
Your SessionHeader element is in the wrong namespace, you have it bound to the V prefix, which is the soap namespace.
dai.odaharadai.odahara
I've got it. Scceeded in loging in by changing header namespace. Thank you very much,