Pages

Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Catching SOAP Faults from CRM 4.0 Web Services

Tuesday, September 20, 2011

post by Keant Weare

A natural follow up to my BizTalk 2010: Calling Dynamics CRM 4.0 Web Services post is one that deals with the Exceptions, or Faults,  that these Web Services may return.  When using the CRM 4.0 Adapter, the adapter would take care of handling SOAP exceptions and bundling them up into a CRM Response message that had a Return Code and Error Nodes.  Whether your operation was successful or not, you could always expect the same type of response message from CRM.
<ns0:Response xmlns:ns0="http://schemas.microsoft.com/crm/BizTalkAdapter/Response">
<Header>
<ReturnCode>1</ReturnCode>
<ErrorCode />
<ErrorString />
<Retryable />
</Header>
Now that we are not using this adapter anymore we need to be able to catch our own exceptions coming out of CRM.  If we don’t perform these actions below(or similar actions) we can expect an error message like the following.

Inner exception: Received unexpected message type 'http://schemas.xmlsoap.org/soap/envelope/#Fault' does not match expected type 'http://schemas.microsoft.com/crm/2007/WebServices#CreateResponse'.
The issue is we have a Solicit Response Send Port in which  we are sending a typed Request message into CRM and are expecting a typed Response message in return.  When we encounter a SOAP Fault, a typed message is being returned, it just isn’t what we are expecting.  In order to avoid these situations, we need to perform the following actions within our BizTalk solution. 
Note: these actions are not specific to CRM, but may be used in other Web Service scenarios.
  • Create a multi-part message that includes a part that is of type BTS.soap_envelope_1__1.Fault.  You will find this schema in the Microsoft.BizTalk.GlobalPropertySchemas assembly.
image
  • Right mouse click on your selected operation and select “New Fault Message”
image
  • Select the Message Type to be the value of our Multi-part message that we just created.
image
  • Add a scope around your send/receive shapes.  The transaction type can be “None” and the Exception Object Type should be set to the Fault that we just created within our Operation.
image
  • So while technically this is defined as a message, within our current scope exception handler it is actually an object.  So if we wanted to dump the contents of this message to the Event Viewer we could perform the following actions by assigning the message to an XML Document and then getting the OuterXml so that we can send this text into the event viewer.
image
  • At this point we can stop if we are so inclined.  If we wanted to actually use this information in our CRM Response message we can assign this “exception” object into an instance of a message that is of the same type (our multi-part message). 
image

  • We then can use a Message Assignment shape to assign this object into an instance of our message.
image
  • Now that we have a typed message, we can use this message in a map to instantiate an instance of our CRM Response.  To keep things simple I am just going to concatenate the faultcode, faultstring and faultactor values and assign to the CreateResult node.  If we wanted to get the actual details out, we will need to write a .Net helper method or use XSLT to extract this content out since we have an untyped “Any” node.
image
  • After all of these changes, our Orchestration should look like this:
image
  • We can now deploy our application and test it.  In order to generate a SOAP Fault, I am going to send in the same message as in my previous post, but this time I am going to make the First Name to be greater than 50 characters.
image
  • Now when we process this message, we will not get an unhandled exception or suspended message.  Instead, we will see an informational message in our event viewer that contains the details that we are interested in.
image
  • Also, we will send this error information to a folder in the form of a CreateResponse message that will include some SOAP Fault details.
<ns0:CreateResponse xmlns:ns1="http://schemas.microsoft.com/crm/2007/CoreTypes" xmlns:ns2="http://microsoft.com/wsdl/types/" xmlns:ns3="http://schemas.microsoft.com/crm/2006/Query" xmlns:ns0="http://schemas.microsoft.com/crm/2007/WebServices" xmlns:ns4="http://schemas.microsoft.com/crm/2006/Scheduling" xmlns:ns5="http://schemas.microsoft.com/crm/2006/WebServices" xmlns:ns6="http://schemas.microsoft.com/crm/2006/CoreTypes">
<ns0:CreateResult>soap:Server - Server was unable to process request. -</ns0:CreateResult>
</ns0:CreateResponse>

Note: some other blog posts mention using an XPATH statement, within our WCF Send Port,  for both types of messages that we are expecting; typed CRM response and SOAP Fault.  In my scenario, this step was not required since I am expecting a typed SOAP Fault exception object within my Scope – Exception handler.
image
Read more ...

BizTalk 2010 WCF Custom Adapter Error : Unable to create binding configuration element for editing. Check the values of the bindyingType and BindingConfiguration properties.

Wednesday, August 31, 2011

Q: 
I have a project that was tested and is working fine in dev. I have exported it from dev and imported it to the production successfully (or at least the I had the impression that it was successful as BizTalk message said so). The project polled a record from Oracle db and does some transformation. We have one test and one production Oracle database. Since it is now in production, I want BizTalk to poll record from the production database and therefore went in the Receive port to configure the database. However, I can not do so as I got this message:
"Unable to create binding configuration element for editing. Check the values of the bindyingType and BindingConfiguration properties. (Microsoft.BizTalk.Adapter.Wcf.Converters.CreateBindingException) Unable to get binding type for binding extension "string". Verify the binding extersion is registered in the machine .config."
Please advise how to solve the issue? I used the import/export MSI to get and put from dev to the production.

Possible Sol 1 :
This error means that custom binding extension for a WCF-Custom or a WCF-CustomIsolated transport was not configured properly. To resolve this error do one or more of the following:
  • Ensure the machine.config file in %WinDir%\Microsoft.NET\Framework\v4.0.30319\Config has the <bindingExtensions> element configured properly.
  • In Windows Explorer, go to %WinDir%\Assembly, and make sure the assemblies implementing the custom binding extension are installed properly.
  • For the WCF-Custom adapter, in the BizTalk Administration console, restart the host instance running the WCF transport.
  • For the WCF-CustomIsolated adapter, in the IIS Management console, restart the application pool hosting the WCF transport.
  • Open and close the BizTalk Administration console if it was opened.
    If you do not have binding for WCF-Custom or WCF-CustomIsolated than first point (machine.config) still applies.
    HTH

    Read more ...

    Polling Updated Records from Database (SQL , Oracle)

    Tuesday, July 5, 2011
    Q: Polling Updated Records from Database (SQL , Oracle)

    I need to poll updated records at each interval of time from a database server there will be records added to the database at random intervals of time so i need to pick up those new added record's each time when i poll (if any exists)

    Ans:

    If you are using Polling with the WCF SQL/Oracle adapter. You can have 2 queries in the statement. First would select the records and just after selecting based on the crieteria update them. For e.g. if you have a status field in the table select the records based on status (where status = 'UNREAD') and after the select query have an update query (update status where status='READ').

    There may be a situation where you would not like to modify the table and would only read the data. But it should be on the database side that you should pick only certain records (based on the crieteria) and should not pick the similar records in the second cycle as you won't require them for processing. Find a way if you can determine this situation.

    Another approach would be to store the primary key into another table (of your database which you can modify) and have a status column with them. Then you can have a join which would determine not to pick up the records which were previously processed
    Read more ...

    Polling Data using Oracle Adapter in Biztalk

    Friday, June 10, 2011

    http://msdn.microsoft.com/en-us/library/dd787944%28v=bts.10%29.aspx


    Configure Transaction Isolation Level and Transaction Timeout
    While performing inbound operation (Polling) using the Microsoft BizTalk Adapter for Oracle Database with BizTalk Server, you should appropriately configure the transaction isolation level and the transaction timeout values. To do this:

    Start the BizTalk Server Administration console.

    In the console tree, expand the BizTalk Group, and then expand Applications.

    Expand the BizTalk application that you have deployed after generating the metadata using the Oracle Database adapter.

    Right-click Receive Ports, point to New, and then click One-way Receive Port.

    In the Receive Port Properties dialog box, on the General tab, type a name for the receive port.

    In the left pane of the Receive Port Properties dialog box, click Receive Locations, and then click New in the right pane to define a new receive location.

    In the Receive Location Properties dialog box, click WCF-Custom in the Type list.

    Click Configure adjacent to the Type list.

    In the WCF-Custom Transport Properties dialog box, click the Behavior tab.

    In the Behavior list, right-click ServiceBehavior, and click Add extension.

    In the Select Behavior Extension dialog box, select oracleDBAdapterInboundTransactionBehavior, and click OK.

    In the left pane of the WCF-Custom Transport Properties, select the oracleDBAdapterInboundTransactionBehavior service under ServiceBehavior.

    In the right pane of the WCF-Custom Transport Properties, specify appropriate values for the transactionIsolationLevel and transactionTimeout parameters. You can select any of the following transaction isolation levels: Serializable, RepeatableRead, ReadCommitted, ReadUncommitted, Snapshot, Chaos, and Unspecified. For information about these transaction isolation levels, see the Members section at http://go.microsoft.com/fwlink/?LinkId=126983.

    Important
    The Oracle Database adapter supports only the following two transaction isolation levels: ReadCommitted and Serializable.

    Click OK in the WCF-Custom Transport Properties dialog box.

    Click OK in the open dialog boxes to save the changes.




    Member nameDescription
    SerializableVolatile data can be read but not modified, and no new data can be added during the transaction.
    RepeatableReadVolatile data can be read but not modified during the transaction. New data can be added during the transaction.
    ReadCommittedVolatile data cannot be read during the transaction, but can be modified.
    ReadUncommittedVolatile data can be read and modified during the transaction.
    SnapshotVolatile data can be read. Before a transaction modifies data, it verifies if another transaction has changed the data after it was initially read. If the data has been updated, an error is raised. This allows a transaction to get to the previously committed value of the data.

    When you try to promote a transaction that was created with this isolation level, an InvalidOperationException is thrown with the error message "Transactions with IsolationLevel Snapshot cannot be promoted".

    ChaosThe pending changes from more highly isolated transactions cannot be overwritten.
    UnspecifiedA different isolation level than the one specified is being used, but the level cannot be determined. An exception is thrown if this value is set.

    The data affected by a transaction is called volatile. When you create a transaction, you can specify the isolation level that applies to the transaction. The isolation level of a transaction determines what level of access other transactions have to volatile data before a transaction completes.

    The lowest isolation level, ReadUncommitted, allows many transactions to operate on a data store simultaneously and provides no protection against data corruption due to interruptive transactions. The highest isolation level, Serializable, provides a high degree of protection against interruptive transactions, but requires that each transaction complete before any other transactions are allowed to operate on the data.

    The isolation level of a transaction is determined when the transaction is created. By default, the System.Transactions infrastructure creates Serializable transactions. You can determine the isolation level of an existing transaction using the IsolationLevel property of a transaction.

    Read more ...