+ Start a Discussion
Abhijit Shrikhande 10Abhijit Shrikhande 10 

[MetadataAPI] Calling service from SoapUI

I am trying to make a call from the SoapUI tool to create a Remote Site Setting on a salesforce instance. I downloaded the Metadata WSDL and set it up in the tool by importing it.

If I make a call to describeMetaData it works as expected.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
   <soapenv:Header>
      <met:CallOptions>
         <met:client>SoapUI</met:client>
      </met:CallOptions>
      <met:SessionHeader>
         <met:sessionId>SessionToken</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <met:describeMetadata>
         <met:asOfVersion>36.0</met:asOfVersion>
      </met:describeMetadata>
   </soapenv:Body>
</soapenv:Envelope>
If I attempt to make a call to create a remote setting using the following request,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
	<soapenv:Header>
		<met:AllOrNoneHeader>
			<met:allOrNone>false</met:allOrNone>
		</met:AllOrNoneHeader>
		<met:CallOptions>
			<met:client>SoapUI</met:client>
		</met:CallOptions>
		<met:SessionHeader>
			<met:sessionId>SESSIONTOKEN</met:sessionId>
		</met:SessionHeader>
	</soapenv:Header>
	<soapenv:Body>
		<met:createMetadata>
			<!--Zero or more repetitions:-->
			<met:metadata>
				<RemoteSiteSetting xmlns="http://soap.sforce.com/2006/04/metadata">
					<description>Used for Apex callout to mapping web service</description>
					<disableProtocolSecurity>false</disableProtocolSecurity>
					<isActive>true</isActive>
					<url>https://www.maptestsite.net/mapping1</url>
					<met:fullName>TestSutieMap</met:fullName>
				</RemoteSiteSetting>
			</met:metadata>
		</met:createMetadata>
	</soapenv:Body>
</soapenv:Envelope>


it fails with the error.
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>
I have tried to force xsi:type="RemoteSiteSetting" on the <met:metadata> tag, but that has not worked either.
 
Abhijit Shrikhande 10Abhijit Shrikhande 10
I have got this working in C# code, but I am still unable to get it going from the SoapUI tool.
Nitish Sharma 7Nitish Sharma 7
Hope your problem is solved now.
This solution is for future readers.
you need to add <xmlns="http://soap.sforce.com/2006/04/metadata"> inside your createmetadata tag.
after that add <xsi:type = "CustomObject"> inside your metadata tag.Give your type as i have given CustomObject.
If got any further errors then do post.
Nitish Sharma 7Nitish Sharma 7
<soapenv:Envelope 
				xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
				xmlns:met="http://soap.sforce.com/2006/04/metadata" 
				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
     
      <met:SessionHeader>
         <met:sessionId>GIVE YOUR SESSIONID HERE</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <met:createMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
         <!--Zero or more repetitions:-->
         <met:metadata xsi:type = "CustomObject">
            <!--Optional:-->
            <met:fullName>Test</met:fullName>
            <met:label>Test</met:label>
            <met:pluralLabel>Tests</met:pluralLabel>
            <met:nameField>
             	<met:label>ID</met:label>
             	<met:type>Text</met:type>	
            </met:nameField>
            <deploymentStatus>Deployed</deploymentStatus>
		  <sharingModel>ReadWrite</sharingModel>
         </met:metadata>
      </met:createMetadata>
   </soapenv:Body>
</soapenv:Envelope>

Try Above code if anyone still facing issues while creating metadata through SoapUI.For me it worked 100%.