You need to sign in to do that
Don't have an account?

SOAP Web Service error
I created apex SOAP web service which accepts attachments and creates the same in SFDC.
for testing I am using "SoapUI" tool for testing.
I am getting below error Please help me out, I am new in web service:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>content-type of the request should be text/xml</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
=====================================================
Please find below request which I am passing:
// Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.sforce.com/schemas/class/SOAPWebservice">
<soapenv:Header>
<soap:AllowFieldTruncationHeader>
<soap:allowFieldTruncation>false</soap:allowFieldTruncation>
</soap:AllowFieldTruncationHeader>
<soap:DebuggingHeader>
<!--Zero or more repetitions:-->
<soap:categories>
<soap:category>Callout</soap:category>
<soap:level>None</soap:level>
</soap:categories>
<soap:debugLevel>None</soap:debugLevel>
</soap:DebuggingHeader>
<soap:CallOptions>
<soap:client></soap:client>
</soap:CallOptions>
<soap:SessionHeader>
<soap:sessionId>00D540000008ju2!AQ4AQNh0Een86V3.P4mMmvbdUTHZQWk0f.XobQ1</soap:sessionId>
</soap:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<soap:candidateInformation>
<soap:name>testUser</soap:name>
<soap:att>
<!--Optional:-->
<soap:content></soap:content>
<!--Optional:-->
<soap:contentType>text/xml</soap:contentType>
<!--Optional:-->
<soap:title>test</soap:title>
</soap:att>
</soap:candidateInformation>
</soapenv:Body>
</soapenv:Envelope>
// SOAP Class
global class createAttachment{
webservice static String createAttachment(String parent, List<MultipleAttachments> multiAtt )
{
try
{
Id parentRecordId=Id.ValueOf(parent);
List<Attachment> listAtt = new List<Attachment>();
for(MultipleAttachments at : multiAtt)
{
Attachment att = new Attachment();
att.Name=at.title;
att.Body=EncodingUtil.base64Decode(at.content);//at.content;
att.ContentType=at.ContentType;
att.parentId=parentRecordId;
listAtt.add(att);
}
insert listAtt;
}
catch(Exception e)
{
system.debug('Exception--> '+e.getMessage());
}
return 'Yes!!!';
}
global class MultipleAttachments
{
webservice String title {get;set;}
webservice String contentType {get;set;}
webservice String content {get;set;}
}
}
for testing I am using "SoapUI" tool for testing.
I am getting below error Please help me out, I am new in web service:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>content-type of the request should be text/xml</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
=====================================================
Please find below request which I am passing:
// Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.sforce.com/schemas/class/SOAPWebservice">
<soapenv:Header>
<soap:AllowFieldTruncationHeader>
<soap:allowFieldTruncation>false</soap:allowFieldTruncation>
</soap:AllowFieldTruncationHeader>
<soap:DebuggingHeader>
<!--Zero or more repetitions:-->
<soap:categories>
<soap:category>Callout</soap:category>
<soap:level>None</soap:level>
</soap:categories>
<soap:debugLevel>None</soap:debugLevel>
</soap:DebuggingHeader>
<soap:CallOptions>
<soap:client></soap:client>
</soap:CallOptions>
<soap:SessionHeader>
<soap:sessionId>00D540000008ju2!AQ4AQNh0Een86V3.P4mMmvbdUTHZQWk0f.XobQ1</soap:sessionId>
</soap:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<soap:candidateInformation>
<soap:name>testUser</soap:name>
<soap:att>
<!--Optional:-->
<soap:content></soap:content>
<!--Optional:-->
<soap:contentType>text/xml</soap:contentType>
<!--Optional:-->
<soap:title>test</soap:title>
</soap:att>
</soap:candidateInformation>
</soapenv:Body>
</soapenv:Envelope>
// SOAP Class
global class createAttachment{
webservice static String createAttachment(String parent, List<MultipleAttachments> multiAtt )
{
try
{
Id parentRecordId=Id.ValueOf(parent);
List<Attachment> listAtt = new List<Attachment>();
for(MultipleAttachments at : multiAtt)
{
Attachment att = new Attachment();
att.Name=at.title;
att.Body=EncodingUtil.base64Decode(at.content);//at.content;
att.ContentType=at.ContentType;
att.parentId=parentRecordId;
listAtt.add(att);
}
insert listAtt;
}
catch(Exception e)
{
system.debug('Exception--> '+e.getMessage());
}
return 'Yes!!!';
}
global class MultipleAttachments
{
webservice String title {get;set;}
webservice String contentType {get;set;}
webservice String content {get;set;}
}
}
NOTE: When adding code please use the "Add a code sample" button (icon <>) to increase readability and make it easier to reference.