Mscrm Dynamics SOAP Send Email From Template - email

I try to create an email with an template email in ms dynamics crm 4 with soap.
I manage to create an simple email and to sent it without problem with soapui.
But when I try with an template email, it not work. here is the soap message.
<web:Execute xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:web="http://schemas.microsoft.com/crm/2007/WebServices">
<web:Request xsi:type="SendEmailFromTemplate">
<web:TemplateId>EA84AF18-FC9-E11-A165-005069A6DB2</web:TemplateId>
<web:RegardingType>invoice</web:RegardingType>
<web:RegardingId>1175670-102-E61-AB42-0050569A6DB</web:RegardingId>
<web:Target xsi:type="TargetSendFromTemplateEmail">
<web:Email>
<activityid>4B165B0-851-611-A42-00505696DB2</activityid>
</web:Email>
</web:Target>
</web:Request>
</web:Execute>
I received this error :
<soap:Body><soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server was unable to process request.</faultstring>
<detail><error>
<code>0x80040216</code>
<description>An unexpected error occurred.</description>
<type>Platform</type>
</error></detail></soap:Fault>
Thank for your help.

I don't have a 4.0 org available, but I executed the message against my 2015 org and captured the request in Fiddler. Here's what the request looked like:
<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
<request i:type="c:SendEmailFromTemplateRequest" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:c="http://schemas.microsoft.com/crm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:Parameters xmlns:d="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<b:KeyValuePairOfstringanyType>
<d:key>TemplateId</d:key>
<d:value i:type="e:guid" xmlns:e="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</d:value>
</b:KeyValuePairOfstringanyType>
<b:KeyValuePairOfstringanyType>
<d:key>RegardingType</d:key>
<d:value i:nil="true"/>
</b:KeyValuePairOfstringanyType>
<b:KeyValuePairOfstringanyType>
<d:key>RegardingId</d:key>
<d:value i:type="e:guid" xmlns:e="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</d:value>
</b:KeyValuePairOfstringanyType>
<b:KeyValuePairOfstringanyType>
<d:key>Target</d:key>
<d:value i:type="b:Entity">
<b:Attributes>
<b:KeyValuePairOfstringanyType>
<d:key>activityid</d:key>
<d:value i:type="e:guid" xmlns:e="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</d:value>
</b:KeyValuePairOfstringanyType>
</b:Attributes>
<b:EntityState i:nil="true"/>
<b:FormattedValues/>
<b:Id>00000000-0000-0000-0000-000000000000</b:Id>
<b:KeyAttributes xmlns:e="http://schemas.microsoft.com/xrm/7.1/Contracts"/>
<b:LogicalName>email</b:LogicalName>
<b:RelatedEntities/>
<b:RowVersion i:nil="true"/>
</d:value>
</b:KeyValuePairOfstringanyType>
</b:Parameters>
<b:RequestId i:nil="true"/>
<b:RequestName>SendEmailFromTemplate</b:RequestName>
</request>
</Execute>
I'm not exactly sure off the top of my head how different the request would look against a 4.0 endpoint, but it still might help you figure out how to structure your request.

Related

Quickbooks InvoiceAdd qbxml format issue

I must be missing out something in the format of my XML file for adding an invoice to Quickbooks Desktop Enterprise US version, my qbxml request is as follows;
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq>
<InvoiceAdd>
<CustomerRef>
<FullName>XXXXXXXXX</FullName>
</CustomerRef>
<ClassRef>
<FullName>XXXXXXX</FullName>
</ClassRef>
<ARAccountRef>
<FullName>XXXXXXXXXX</FullName>
</ARAccountRef>
<TemplateRef>
<FullName>Standard invoice</FullName>
</TemplateRef>
<TxnDate/>
<RefNumber>83434</RefNumber>
<BillAddress>
<Addr1>4xxxxxx</Addr1>
<City>xxxxxxxx</City>
<State>XX</State>
<PostalCode>0000</PostalCode>
</BillAddress>
<IsPending>1</IsPending>
<IsFinanceCharge>0</IsFinanceCharge>
<PONumber>12345</PONumber>
<TermsRef>
<FullName>Net 30</FullName>
</TermsRef>
<DueDate/>
<SalesRepRef/>
<FOB/>
<ShipDate/>
<ShipMethodRef/>
<ItemSalesTaxRef/>
<Memo/>
<CustomerMsgRef/>
<IsToBePrinted>0</IsToBePrinted>
<IsToBeEmailed>0</IsToBeEmailed>
<IsTaxIncluded>0</IsTaxIncluded>
<CustomerSalesTaxCodeRef/>
<Other/>
<ExchangeRate>1</ExchangeRate>
<SetCredit>
<CreditTxnID>1</CreditTxnID>
<AppliedAmount>0</AppliedAmount>
<Override>1</Override>
</SetCredit>
<InvoiceLineAdd>
<itemRef>
<FullName>S-check UT</FullName>
</itemRef>
<Desc>Interpreter</Desc>
<Quantity>1</Quantity>
<UnitOfMeasure/>
<Rate>10</Rate>
<RatePercent>100</RatePercent>
<PriceLevelRef/>
<ClassRef/>
<Amount>10</Amount>
<OptionForPriceRuleConflict>0</OptionForPriceRuleConflict>
<InventorySiteRef/>
<InventorySiteLocationRef/>
<SerialNumber/>
<LotNumber/>
<ServiceDate/>
<SalesTaxCodeRef/>
<OverrideItemAccountRef/>
<Other1/>
<Other2/>
<LinkToTxn>
<TxnID>0</TxnID>
<TxnLineID>0</TxnLineID>
</LinkToTxn>
<DataExt>
<OwnerID>3caa4f6f-fcb3-4767-99e6-0ba5dfd34e8f</OwnerID>
<DataExtName>Sample</DataExtName>
<DataExtValue>Sample</DataExtValue>
</DataExt>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>
When i check this xml request using the qbxml validator i'm getting the following error message even though i have supplied all the required fields as outlined in the OSR tool;
Line: 53
LinePos: 20
Src Text: <itemRef>
Reason: Element content is invalid according to the DTD/Schema.
Expecting: ItemRef, Desc, Quantity, UnitOfMeasure, Rate, RatePercent, PriceLevelRef, ClassRef,
Amount, TaxAmount, OptionForPriceRuleCon....
I'm not sure about what's wrong with my xml file, when i run the quickbooks webconnector, the error message i get is;
Message: QuickBooks found an error when parsing the provided XML text stream.
I understand this is coming up because of the wrong format of my qbxml request which could be incorrect. Kindly assist
I have filtered your QBXML and removed all error producing QBXML tags
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq>
<InvoiceAdd>
<CustomerRef>
<FullName>XXXXXXXXX</FullName>
</CustomerRef>
<ClassRef>
<FullName>XXXXXXX</FullName>
</ClassRef>
<ARAccountRef>
<FullName>XXXXXXXXXX</FullName>
</ARAccountRef>
<TemplateRef>
<FullName>Standard invoice</FullName>
</TemplateRef>
<TxnDate/>
<RefNumber>83434</RefNumber>
<BillAddress>
<Addr1>4xxxxxx</Addr1>
<City>xxxxxxxx</City>
<State>XX</State>
<PostalCode>0000</PostalCode>
</BillAddress>
<IsPending>1</IsPending>
<IsFinanceCharge>0</IsFinanceCharge>
<PONumber>12345</PONumber>
<TermsRef>
<FullName>Net 30</FullName>
</TermsRef>
<DueDate/>
<SalesRepRef/>
<FOB/>
<ShipDate/>
<ShipMethodRef/>
<ItemSalesTaxRef/>
<Memo/>
<CustomerMsgRef/>
<IsToBePrinted>0</IsToBePrinted>
<IsToBeEmailed>0</IsToBeEmailed>
<IsTaxIncluded>0</IsTaxIncluded>
<CustomerSalesTaxCodeRef/>
<Other/>
<ExchangeRate>1</ExchangeRate>
<SetCredit>
<CreditTxnID>1</CreditTxnID>
<AppliedAmount>0</AppliedAmount>
<Override>1</Override>
</SetCredit>
<InvoiceLineAdd>
<Desc>Interpreter</Desc>
<Quantity>1</Quantity>
<UnitOfMeasure/>
<Rate>10</Rate>
<ClassRef/>
<Amount>10</Amount>
<InventorySiteRef/>
<InventorySiteLocationRef/>
<SerialNumber/>
<ServiceDate/>
<SalesTaxCodeRef/>
<OverrideItemAccountRef/>
<Other1/>
<Other2/>
<LinkToTxn>
<TxnID>0</TxnID>
<TxnLineID>0</TxnLineID>
</LinkToTxn>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>

Basic auth credentials using headers in soap on groovy

I'm trying to connect to WSDL server, which requires basic auth along with the body. I tried hitting with SOAPUI, and was able to do so. While working for the same in groovy and using wslite package for SOAP call, I'm getting error as "Password required".
I tried the tutorial on https://github.com/jwagenleitner/groovy-wslite, but the method described (in Usage block) didn't help.
I'm using groovy for this.
Below is the raw code from SOAP UI, with response 200OK
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:w="http://xmlns.oracle.com/Enterprise/Tools/schemas/W_CHKLST_CREATE_REQ.1">
<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-83C962CC24EAB67F1D15586306447678"><wsse:Username>userName</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">JLTdeK6Yg3D64+2qz5xnbA==</wsse:Nonce><wsu:Created>2019-05-23T16:57:24.767Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
<soapenv:Body>
<w:helloWorld/>
</soapenv:Body>
</soapenv:Envelope>
which results in a 200OK from SOAPUI
HTTP/1.1 200 OK
Date: Wed, 22 May 2019 21:54:12 GMT
Content-Type: text/xml; charset=UTF-8
Content-Length: 3570
My Groovy Code,
def client = new SOAPClient("URL of WSDL")
def response = client.send(SOAPAction: "someAction",
connectTimeout:10000,
readTimeout:20000,
useCaches:false,
followRedirects:false) {
version SOAPVersion.V1_2 // SOAPVersion.V1_1 is default
soapNamespacePrefix "soapenv" // "soap-env" is default
envelopeAttributes "xmlns:ns":"http://example.weather.org"
header {
security("xmlns:ns20":"http://SecurityOpenXSD"){
"ns20:Username"("username")
"ns20:Password"("password")
}
}
body {
"ns:helloWorld" {
}
}
}
which gives soap xml as
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand='1'
xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
<wsse:UsernameToken wsu:Id='UsernameToken-83C962CC24EAB67F1D15586299636605'>
<wsse:Username>userName</wsse:Username>
<wsse:Password
Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>
password
</wsse:Password>
<wsse:Nonce
EncodingType='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'>
JLTdeK6Yg3D64+2qz5xnbA==
</wsse:Nonce>
<wsu:Created>2019-05-23T10:07:52.913Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
But i get error as password required,
<?xml version="1.0" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<Code><Value>SOAP-ENV:Receiver</Value></Code>
<Reason><Text>null</Text></Reason>
<Detail><IBResponse type="error" xmlns=""><DefaultTitle> Error Response</DefaultTitle>
<StatusCode>20</StatusCode>
<DefaultMessage><![CDATA[User Password required]]></DefaultMessage>
</IBResponse></Detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

Fedex Delivery Date

I'm tracking a order using SOAP API for my website to get delivery date of the ordered item through Postman , it is running successfully but I'm getting only ship date and Actual pickup date ,I need to get delivery date and transit date if possible.
Here is my code which I'm sending :
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v14="http://fedex.com/ws/track/v14">
<soapenv:Header/>
<soapenv:Body>
<v14:TrackRequest>
<v14:WebAuthenticationDetail>
<v14:UserCredential>
<v14:Key>userkey</v14:Key>
<v14:Password>userpassword</v14:Password>
</v14:UserCredential>
</v14:WebAuthenticationDetail>
<v14:ClientDetail>
<v14:AccountNumber>user account number</v14:AccountNumber>
<v14:MeterNumber>meter number</v14:MeterNumber>
</v14:ClientDetail>
<v14:TransactionDetail>
<v14:CustomerTransactionId>Track By
Number_v14</v14:CustomerTransactionId>
<v14:Localization>
<v14:LanguageCode>EN</v14:LanguageCode>
<v14:LocaleCode>US</v14:LocaleCode>
</v14:Localization>
</v14:TransactionDetail>
<v14:Version>
<v14:ServiceId>trck</v14:ServiceId>
<v14:Major>14</v14:Major>
<v14:Intermediate>0</v14:Intermediate>
<v14:Minor>0</v14:Minor>
</v14:Version>
<v14:SelectionDetails>
<v14:CarrierCode>FDXE</v14:CarrierCode>
<v14:PackageIdentifier>
<v14:Type>TRACKING_NUMBER_OR_DOORTAG</v14:Type>
<v14:Value>trackingnumber</v14:Value>
</v14:PackageIdentifier>
<v14:ShipmentAccountNumber/>
<v14:SecureSpodAccount/>
<v14:Destination>
<v14:GeographicCoordinates/>
</v14:Destination>
</v14:SelectionDetails>
<v14:ProcessingOptions>INCLUDE_DETAILED_SCANS</v14:ProcessingOptions>
</v14:TrackRequest>
</soapenv:Body>
</soapenv:Envelope>
and in response I'm getting this :
<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<TrackReply xmlns="http://fedex.com/ws/track/v14">
<HighestSeverity>SUCCESS</HighestSeverity>
<Notifications>
<Severity>SUCCESS</Severity>
<Source>trck</Source>
<Code>0</Code>
<Message>Request was successfully processed.</Message>
<LocalizedMessage>Request was successfully processed.</LocalizedMessage>
</Notifications>
<TransactionDetail>
<CustomerTransactionId>Track By Number_v14</CustomerTransactionId>
<Localization>
<LanguageCode>EN</LanguageCode>
<LocaleCode>US</LocaleCode>
</Localization>
</TransactionDetail>
<Version>
<ServiceId>trck</ServiceId>
<Major>14</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<CompletedTrackDetails>
<HighestSeverity>SUCCESS</HighestSeverity>
<Notifications>
<Severity>SUCCESS</Severity>
<Source>trck</Source>
<Code>0</Code>
<Message>Request was successfully processed.</Message>
<LocalizedMessage>Request was successfully processed.</LocalizedMessage>
</Notifications>
<DuplicateWaybill>false</DuplicateWaybill>
<MoreData>false</MoreData>
<TrackDetailsCount>0</TrackDetailsCount>
<TrackDetails>
<Notification>
<Severity>SUCCESS</Severity>
<Source>trck</Source>
<Code>0</Code>
<Message>Request was successfully processed.</Message>
<LocalizedMessage>Request was successfully processed.</LocalizedMessage>
</Notification>
<TrackingNumber>trackingnumber</TrackingNumber>
<TrackingNumberUniqueIdentifier>uniquetrackingnumberFDEG</TrackingNumberUniqueIdentifier>
<StatusDetail>
<Location>
<Residential>false</Residential>
</Location>
</StatusDetail>
<CarrierCode>FDXG</CarrierCode>
<OperatingCompanyOrCarrierDescription>FedEx Ground</OperatingCompanyOrCarrierDescription>
<Service>
<Type>FEDEX_GROUND</Type>
</Service>
<PackageSequenceNumber>0</PackageSequenceNumber>
<PackageCount>0</PackageCount>
<DatesOrTimes>
<Type>ACTUAL_PICKUP</Type>
<DateOrTimestamp>2018-02-01T00:00:00</DateOrTimestamp>
</DatesOrTimes>
<DatesOrTimes>
<Type>SHIP</Type>
<DateOrTimestamp>2018-02-01T00:00:00</DateOrTimestamp>
</DatesOrTimes>
<DeliveryAttempts>0</DeliveryAttempts>
<TotalUniqueAddressCountInConsolidation>0</TotalUniqueAddressCountInConsolidation>
<DeliveryOptionEligibilityDetails>
<Option>INDIRECT_SIGNATURE_RELEASE</Option>
<Eligibility>INELIGIBLE</Eligibility>
</DeliveryOptionEligibilityDetails>
<DeliveryOptionEligibilityDetails>
<Option>REDIRECT_TO_HOLD_AT_LOCATION</Option>
<Eligibility>INELIGIBLE</Eligibility>
</DeliveryOptionEligibilityDetails>
<DeliveryOptionEligibilityDetails>
<Option>REROUTE</Option>
<Eligibility>INELIGIBLE</Eligibility>
</DeliveryOptionEligibilityDetails>
<DeliveryOptionEligibilityDetails>
<Option>RESCHEDULE</Option>
<Eligibility>INELIGIBLE</Eligibility>
</DeliveryOptionEligibilityDetails>
</TrackDetails>
</CompletedTrackDetails>
</TrackReply>
</SOAP-ENV:Body>
Notes:- I'm passing no headers since in fedex documentation ,nothing is mention about them.

Spring Integration should route Message (with SOAP Headers)

I am trying to write configure a gateway, which should take a complete SOAP Message and then delegate it to another SOAP Provider (incl. all SOAP headers of the first request).
What I have done so far:
1) web.xml
MessageDispatcherServlet with Mapping:
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/appservices/*</url-pattern>
</servlet-mapping>
2) Configuration with an Endpoint-Mapping
<bean class="org.springframework.ws.server.endpoint.mapping.UriEndpointMapping">
<property name="defaultEndpoint" ref="ws-in-gw"/>
</bean>
3) Configuration of Spring Integration inbound-gateway and outbound-gateway
<int-ws:inbound-gateway id="ws-in-gw"
request-channel="in"
reply-channel="out"
mapped-request-headers="*" />
<int:channel id="in" />
<int:channel id="out" />
<int-ws:outbound-gateway
id="ws-out-gw-status"
request-channel="in-status"
reply-channel="out-status"
uri="http://${delegationServer}/${delegation.contextroot}/soap/AnotherService"
interceptor="soapEnricher"
</int-ws:outbound-gateway>
<bean id="soapEnricher" class="foo.bar.SoapHeaderEnricher" />
public class SoapHeaderEnricher implements ClientInterceptor {
#Override
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
try {
SoapMessage soapMessage = (SoapMessage) messageContext.getRequest();
SoapHeader sh = soapMessage.getSoapHeader();
// can use sh.addHeaderElement(new QName(...)) now, but where are the original Headers???
} catch () {
}
}
My first Problem was, that the original SOAP Headers had been cut of, so I introduced the ' mapped-request-headers="*" ' attribute at the inbound gateway.
When I now configure a wire-tap, I see the Headers (myToken:MySecretToken) are received:
DEBUG 10:46:53 - [Payload DOMSource content=javax.xml.transform.dom.DOMSource#24a6ce98][Headers={errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel#43456ff4, myToken:MySecretToken=org.springframework.ws.soap.saaj.SaajSoapHeaderElement#3b91ead, ...}]
This is the SOAP Message for my test:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:stat="http://status.service.promakler.provinzial.com/">
<soapenv:Header>
<myToken:MySecretToken xmlns=""
xmlns:myToken="http://foo.bar">12345</myToken:MySecretToken>
</soapenv:Header>
<soapenv:Body>
<stat:getStatus/>
</soapenv:Body>
</soapenv:Envelope>
So the Headers are now in my Message, but in the ClientInterceptor, there is no way to get the Headers (just the payload)?! I can add new Headers, but how can I get the original Header?
Can anybody give me a hint (or perhaps there is even a quiet simpler solution??)
Regards
Timo
Try to introduce a custom extension of DefaultSoapHeaderMapper and override populateUserDefinedHeader to extract those SaajSoapHeaderElement from the MessageHeaders and populate them to the SoapHeader. And finally inject your solution to the header-mapper of your <int-ws:outbound-gateway>.

How can create a case entity in Microsoft Dynamics CRM 2013 using SOAP API?

I'm having trouble creating a Case (aka Incident) entity using the MS Dynamics CRM 2013 SOAP API. I think I've narrowed it down to a troublesome customerid a customeridtype related reference, but haven't been able to solve it despite quite a bit of research.
Here's the create XML I'm using:
<create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<entity>
<b:attributes>
<b:keyvaluepairofstringanytype>
<c:key>customerid</c:key>
<c:value i:type="b:EntityReference">
<b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id>
<b:logicalname>account</b:logicalname>
<b:name>Testing Account</b:name>
</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>new_email</c:key>
<c:value i:type="d:string">test#domain.com</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>new_phone</c:key>
<c:value i:type="d:string">111-222-3333</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>description</c:key>
<c:value i:type="d:string">This is a test. Please do not respond to this case.</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>statuscode</c:key>
<c:value i:type="b:OptionSetValue">
<b:value>1</b:value>
</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>prioritycode</c:key>
<c:value i:type="b:OptionSetValue">
<b:value>2</b:value>
</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>new_date</c:key>
<c:value i:type="d:dateTime">2014-12-06T09:56:00</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>new_cstadmin</c:key>
<c:value i:type="b:OptionSetValue">
<b:value>100000015</b:value>
</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>title</c:key>
<c:value i:type="d:string">Test Case by XYZ</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>subjectid</c:key>
<c:value i:type="b:EntityReference">
<b:id>41b106d1-074a-e411-b697-9cb654957388</b:id>
</c:value>
</b:keyvaluepairofstringanytype>
</b:attributes>
<b:logicalname>incident</b:logicalname>
</entity>
</create>
When I submit this, I get an HTTP-500 back, with the error,
You should specify a parent contact or account
I assume that means that this chunk of xml...
<b:keyvaluepairofstringanytype>
<c:key>customerid</c:key>
<c:value i:type="b:EntityReference">
<b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id>
<b:logicalname>account</b:logicalname>
<b:name>Testing Account</b:name>
</c:value>
</b:keyvaluepairofstringanytype>
...does not adequately reference the parent account for the case. So I assume my syntax is incorrect somehow. The reason I choose this syntax is that it reflects the same form that is returned when I RETRIEVE a case.
I've also tried a slightly different syntax by preparing "customerid" and "customeridtype" attributes as separate key-value pairs, such as:
<b:keyvaluepairofstringanytype>
<c:key>customeridtype</c:key>
<c:value i:type="d:string">account</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>customerid</c:key>
<c:value i:type="b:EntityReference">
<b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id>
</c:value>
</b:keyvaluepairofstringanytype>
...but still, no dice.
Anyone have any ideas?
AFAIK customerid and customeridtype should both be there (because of the special "customer" field structure) so I'd try to mix your two attempts:
<b:keyvaluepairofstringanytype>
<c:key>customerid</c:key>
<c:value i:type="b:EntityReference">
<b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id>
<b:logicalname>account</b:logicalname>
<b:name>Testing Account</b:name>
</c:value>
</b:keyvaluepairofstringanytype>
<b:keyvaluepairofstringanytype>
<c:key>customeridtype</c:key>
<c:value i:type="d:string">1</c:value>
</b:keyvaluepairofstringanytype>
Note that customeridtype contains the type code as a number in my attempt
<c:value i:type="d:string">1</c:value>
That said, as a side note, if you can make it so your data comes out as JSON you could POST it to the OData service (resulting in a less painful experience).
The Customer field is a really special one so, rather than passing an EntityReference to the account, try to pass a "b:Customer" object instead and see if works?
Also, donĀ“t waste time generating the request manually, use SDK tools like Sdk.Soap.js for SOAP or the REST endpoint (much simpler).