How to access postgreSQL database using Mule pattern? - postgresql

Im able to log some message but how to change it to access a database and send those messages and store there?
i know the database part is disconected from the pattern but tried somethings and nothing worked so far..
code:
<scripting:transformer name="noopLoggingTransformer">
<scripting:script engine="groovy">
log.info "insert into inbound_messages (payload, timestamp, agent, ip_from, endpoint, soap_operation) values ('',now(), ${message.getInboundProperty('user-agent')}, ${message.getInboundProperty('MULE_REMOTE_CLIENT_ADDRESS')}, ${message.getInboundProperty('http.request')}, '');"
message
</scripting:script>
</scripting:transformer>
<pattern:web-service-proxy name="service" transformer-refs="noopLoggingTransformer" inboundAddress="${serverName}/services/Logradouros/LogradouroServico" outboundAddress="${targetServer}/servicos/v2/LogradouroServico.svc" wsdlFile="LogradouroServicos.wsdl">
</pattern:web-service-proxy>
<jdbc-ee:postgresql-data-source name="dbconection" user="${database.user}" password="${database.pass}" url="${database.url}" transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source">
</jdbc-ee:postgresql-data-source>
<jdbc-ee:connector name="jdbcConnector" dataSource-ref="dbconection" validateConnections="false" transactionPerMessage="true" queryTimeout="10" pollingFrequency="10000" doc:name="JDBC">
<jdbc-ee:query key="querymsg" value="insert into inbound_messages (payload, timestamp, agent, ip_from, endpoint, soap_operation) values ('', now(), '','','')"></jdbc-ee:query>
</jdbc-ee:connector>
What i did after was try a different aproach:
<flow name="logradouros-autenticacao" doc:name="logradouros-autenticacao">
<servlet:inbound-endpoint path="${webservice.logradouros.in.autenticacao.path}" responseTimeout="10000" doc:name="HTTP"></servlet:inbound-endpoint>
<async doc:name="Async">
<flow-ref name="log-request" doc:name="Flow Reference"></flow-ref>
</async>
<outbound-endpoint exchange-pattern="request-response" address="${webservice.logradouros.out.protocol}://${webservice.logradouros.out.host}/${webservice.logradouros.out.autenticacao.path}" doc:name="Generic"></outbound-endpoint>
</flow>
<flow name="log-request" doc:name="log-request">
<logger message="1-> #[groovy:payload.getClass()]" level="INFO" doc:name="Logger"></logger>
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="insertMsg" responseTimeout="10000" queryTimeout="-1" connector-ref="jdbcConnector" doc:name="Persist raw message"></jdbc-ee:outbound-endpoint>
<logger message="#[header:INBOUND:Host] #[header:INBOUND:http.method] #[message.inboundProperties.entrySet().toString()] #[groovy:payload.toString()] #[groovy: return message.getInboundPropertyNames().toString()] #[groovy: return message.getInboundProperty('request.parameters').toString()]" level="INFO" category="mule.http.accesslog" doc:name="Logger"></logger>
<logger message="#[message.outboundProperties.entrySet().toString()]" level="INFO" category="mule.http.accesslog" doc:name="Logger"></logger>
</flow>
its not 100% but it may workout, the approach through pattern wasnt working...

In your transformer, use muleContext.client to dispatch messages to VM queue consumed by another flow, which will take care of insert data in the DB.
So in your case, something similar to the following should work:
<scripting:transformer name="noopLoggingTransformer">
<scripting:script engine="groovy">
muleContext.client.dispatch('vm://log-request.in', message)
message
</scripting:script>
</scripting:transformer>
<pattern:web-service-proxy name="service" transformer-refs="noopLoggingTransformer" inboundAddress="${serverName}/services/Logradouros/LogradouroServico" outboundAddress="${targetServer}/servicos/v2/LogradouroServico.svc" wsdlFile="LogradouroServicos.wsdl" />
<flow name="log-request" doc:name="log-request">
<vm:inbound-endpoint path="log-request.in" />
<logger message="1-> #[groovy:payload.getClass()]" level="INFO" doc:name="Logger" />
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="insertMsg" responseTimeout="10000" queryTimeout="-1" connector-ref="jdbcConnector" doc:name="Persist raw message" />
<!-- TODO use MEL, not these old style expressions -->
<logger message="#[header:INBOUND:Host] #[header:INBOUND:http.method] #[message.inboundProperties.entrySet().toString()] #[groovy:payload.toString()] #[groovy: return message.getInboundPropertyNames().toString()] #[groovy: return message.getInboundProperty('request.parameters').toString()]" level="INFO" category="mule.http.accesslog" doc:name="Logger" />
<logger message="#[message.outboundProperties.entrySet().toString()]" level="INFO" category="mule.http.accesslog" doc:name="Logger" />
</flow>

Related

Camel-SQL route ServiceUnavailableException when using header value as parameter

In ApacheServiceMix 7.0.0 I have defined the following routes using Blueprint:
<reference id="dataSource" interface="javax.sql.DataSource" filter="(dataSourceName=connectuserdata)" />
<bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="dataSource" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<package>com.focuscura</package>
<dataFormats>
<!-- here we define a Json data format with the id jack and that it should use the TestPojo as the class type when
doing unmarshal. The unmarshalTypeName is optional, if not provided Camel will use a Map as the type -->
<json id="userdata" library="Jackson" />
</dataFormats>
<route id="connect.userdata_create">
<from uri="jetty:http://localhost:8881/userdata?httpMethodRestrict=POST"/>
<unmarshal ref="userdata"/>
<!--<process ref="scalaUserDataProcessor"/>-->
<log message="Received new userdata" />
<to uri="sql:INSERT INTO public."UserData" (lastname, firstname) VALUES (:#lastname , :#firstname)"/>
</route>
<route id="connect.userdata_get2">
<from uri="jetty:http://localhost:8881/userdata2?httpMethodRestrict=GET"/>
<to uri="sql:SELECT * FROM public."UserData" WHERE id = :#id"/>
<!--<process ref="scalaUserDataProcessor"/>-->
<marshal ref="userdata"/>
</route>
</camelContext>
The Datasource is installed as a seperate service following the instructions as described in this post: How can I install postgresqljdbc to work in Karaf OSGi?
This is working fine! I can post JSON to the Jetty URL and it is inserted into the database.
But when I try to get data from this Endpoint I get the following error
org.osgi.service.blueprint.container.ServiceUnavailableException: The Blueprint container is being or has been destroyed: (&(dataSourceName=connectuserdata)(objectClass=javax.sql.DataSource))
at org.apache.aries.blueprint.container.ReferenceRecipe.getService(ReferenceRecipe.java:241)
at org.apache.aries.blueprint.container.ReferenceRecipe.access$000(ReferenceRecipe.java:56)
at org.apache.aries.blueprint.container.ReferenceRecipe$ServiceDispatcher.call(ReferenceRecipe.java:306)
at Proxyb6abdd30_6f59_4e89_a419_c4ff0558aa62.equals(Unknown Source)
at java.util.WeakHashMap.eq(WeakHashMap.java:287)
at java.util.WeakHashMap.get(WeakHashMap.java:401)
at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:204)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:140)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.
(SQLErrorCodeSQLExceptionTranslator.java:103)
at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605)
at org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:100)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:191)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:146)
at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:43)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
The weird thing is, that when I substitute <to uri="sql:SELECT * FROM public."UserData" WHERE id = **:#id**"/> with <to uri="sql:SELECT * FROM public."UserData" WHERE id = **2**"/>
it works fine again and I get a nice little JSON of user nr 2 returned.
Any hints as to how to solve this?
The problem wasn't really in my route or camel. It was caused by PostgreSQL. By using a parameter in my route I needed to provide an explicit typecast.
To get this working I needed to add ::bigint to the parameter in my route: sql:SELECT lastname FROM public."UserData" WHERE id = :#id::bigint?dataSource=dataSource&allowNamedParameters=true
For some reason the error from Postgres was swallowed by Camel-sql and I got the weird message about Datasource being destroyed.
Thanks everybody for your helpful comments and questions!

How to remove Mule Headers from SOAP response

I have a requirement where I need to expose a SOAP webservice .. So I have the following Mule flow :-
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="Flow1" doc:name="Flow1" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" doc:name="SOAP"/>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<jms:outbound-endpoint queue="NewQueue" connector-ref="Active_MQ" doc:name="JMS" exchange-pattern="request-response"/>
<logger message="Response2 :- #[message.payload]" level="INFO" doc:name="Logger"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
</flow>
<flow name="flow2" doc:name="flow2" >
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:NewQueue" doc:name="JMS" exchange-pattern="request-response" disableTemporaryReplyToDestinations="true" responseTimeout="90000"/>
<set-variable variableName="SOAPRequest" value="#[message.payload]" doc:name="Variable"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl">
<method-entry-point-resolver>
<include-entry-point method="retrieveDataOperation"/>
<include-entry-point method="insertDataOperation"/>
<include-entry-point method="updateDataOperation"/>
<include-entry-point method="deleteDataOperation"/>
</method-entry-point-resolver>
</component>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
</flow>
Here you can see the request is getting into JMS queue from the first flow and the second flow use JMS inbound takes it from the JMS queue and the webservice implemented class proccess it .. Now the service works fine without any issue .. the only issue is it get Mule Header in the SOAP in the response like the following :-
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<mule:header xmlns:mule="http://www.muleumo.org/providers/soap/1.0">
<mule:MULE_CORRELATION_ID>ID:ANIRBAN-PC-49483-1408719168461-1:1:10:1:1</mule:MULE_CORRELATION_ID>
<mule:MULE_CORRELATION_GROUP_SIZE>-1</mule:MULE_CORRELATION_GROUP_SIZE>
<mule:MULE_CORRELATION_SEQUENCE>-1</mule:MULE_CORRELATION_SEQUENCE>
</mule:header>
</soap:Header>
<soap:Body>
<deleteDataResponse xmlns="http://services.test.com/schema/MainData/V1">
<Response>Data not exists !!! Please provide correct ID</Response>
<Id>0</Id>
<Age>0</Age>
</deleteDataResponse>
</soap:Body>
</soap:Envelope>
Now please help me to remove the Mule headers from the SOAP response .. I tried with the following :- <cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" enableMuleSoapHeaders="false" doc:name="SOAP"/> but no use .. it's still showing the Mule headers .. Please help ..
You can potentially get away with a temporary workaround until the enableMuleSoapHeaders="false" issue gets solved, by either:
Adding a between the HTTP inbound endpoint and the CXF service ; in order to remove the undue SOAP headers but XSL-Transformation
Using delete-message-property to remove the MULE_* props at the end of Flow1, right after the mulexml:xml-to-object-transformer
I also found an alternate solution off adding it to cxf:outInterceptors
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" doc:name="SOAP">
<cxf:outInterceptors >
<spring:bean id="outfault" class="com.test.services.schema.SOAPOptionalData.SOAPInterceptorOutboundHeaderRemover"/>
</cxf:outInterceptors>
</cxf:jaxws-service>
And in the Java class :-
public class SOAPInterceptorOutboundHeaderRemover extends AbstractSoapInterceptor {
public SOAPInterceptorOutboundHeaderRemover() {
super(Phase.PRE_PROTOCOL);
}
#Override
public void handleMessage(SoapMessage arg0) throws Fault {
List<Header> headerList = arg0.getHeaders();
Header muleHeader = null;
boolean isMuleHeader = false;
for (Header header : headerList) {
ElementNSImpl element = (ElementNSImpl) header.getObject();
if ("mule:header".equals(element.getNodeName())) {
isMuleHeader = true;
muleHeader = header;
}
}
if (isMuleHeader) {
arg0.getHeaders().remove(muleHeader);
}
}
}
And this is also working fine

Example for adding attachment to email at mule

I would like to ask how to add file as attachment in Mule (3.4.0)?
I tried many solutions and googled a lot but haven't found anything good.
This is what I have now (last try before posting here):
<sub-flow name="sendBackMail" doc:name="sendBackMail">
<set-attachment attachmentName="changed.xml" value="#[payload]" contentType="text/xml" doc:name="Attachment"/>
<logger message="Attachment ok" level="INFO" doc:name="Logger"/>
<file:file-to-byte-array-transformer doc:name="File to Byte Array"/>
<logger message="Attachment ok. Message: #[message]" level="INFO" doc:name="Logger"/>
<smtps:outbound-endpoint host="${mailSMTP}" port="${mailSendPort}"
user="${mailUser}" password="${mailPass}" to="${receiver}"
from="${mailUser}" responseTimeout="60000" doc:name="SMTP"
connector-ref="SMTP" mimeType="text/xml" subject="msp2bass" >
</smtps:outbound-endpoint>
</sub-flow>
It sends mail but I get content of xml file as body of mail.
What should I do/change so that mail would be sent as attachment. I get file from another sevice, do XSLT on it and then I should send it to some mail.
Any more info I should provide?
Thank you!
EDIT
How I call bean:
<spring:bean id="SetAttachment" name="SetAttachment" class="si.irose.msp.cust.bass.SetAttachment">
</spring:bean>
<component doc:name="Java">
<spring-object bean="SetAttachment"/>
</component>
Java class:
package si.irose.msp.cust.bass;
import org.mule.api.MuleEventContext;
import org.mule.api.MuleMessage;
import org.mule.api.lifecycle.Callable;
public class SetAttachment implements Callable{
private MuleMessage mule;
private String name;
#Override
public Object onCall(MuleEventContext eventContext) throws Exception {
mule = eventContext.getMessage();
String tryit="routeid";
for (int i=0;i<mule.getInvocationPropertyNames().toArray().length;i++) {
if (mule.getInvocationPropertyNames().toArray()[i].equals(tryit)) {
name=mule.getInvocationProperty(mule.getInvocationPropertyNames().toArray()[i].toString()).toString();
break;
}
}
mule.addOutboundAttachment(name, mule.getInvocationProperty(name), "text/xml");
return null;
}
}
Ok issue solved.
When you read from file inbound or generate with quartz (string or file) you can add "Attachment" directly BUT if you do an XSLT transformation and then try to send that payload via smtp, then you need to add "Object to String" transformer before attachment.
Final working solution:
<sub-flow name="sendBackMail" doc:name="sendBackMail">
<object-to-string-transformer doc:name="Object to String"/>
<set-attachment attachmentName="changed.xml" value="#[payload]" contentType="text/xml" doc:name="Attachment"/>
<logger message="Attachment ok" level="INFO" doc:name="Logger"/>
<file:file-to-byte-array-transformer doc:name="File to Byte Array"/>
<logger message="Attachment ok. Message: #[message]" level="INFO" doc:name="Logger"/>
<smtps:outbound-endpoint host="${mailSMTP}" port="${mailSendPort}"
user="${mailUser}" password="${mailPass}" to="${receiver}"
from="${mailUser}" responseTimeout="60000" doc:name="SMTP"
connector-ref="SMTP" mimeType="text/xml" subject="msp2bass" >
</smtps:outbound-endpoint>
</sub-flow>
I haven't checked yet what transformer you need to apply if you do any other job instead of XSLT so if anyone wish to add some knowledge to this then please do so and add comment.
You need to use set-payload before the smtps:outbound-endpoint to set the body of the email to whatever you want, otherwise it will contain the same value attached with set-attachment.
Also remove the file:file-to-byte-array-transformer: it's unclear what it's there for.

Mule HTTP java.io.IOException: Attempted read on closed stream

When I used two HTTP endpoints in a flow, Mule throws this exception. I've found the way to deal with this problem: use the second HTTP endpoint in asynchronous mode, but it is not a good way.
ERROR DefaultSystemExceptionStrategy [[testdemo].connector.http.mule.default.receiver.03]: Caught exception in Exception Strategy: Attempted read on closed stream.
java.io.IOException: Attempted read on closed stream.
at org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:126)
at org.mule.model.streaming.DelegatingInputStream.read(DelegatingInputStream.java:58)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1025)
at org.mule.transformer.simple.ObjectToOutputHandler$3.write(ObjectToOutputHandler.java:76)
at org.mule.transport.http.HttpServerConnection.writeResponse(HttpServerConnection.java:315)
at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:164)
at org.mule.work.WorkerContext.run(WorkerContext.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
my code :
<flow doc:name="httpPost" name="httpPost">
<http:inbound-endpoint doc:name="HTTP" keep-alive="true"
exchange-pattern="request-response" host="localhost" path="service"
port="8082" />
<http:body-to-parameter-map-transformer />
<!-- This component is just set to show the message accecpted from the request -->
<scripting:component>
<scripting:script engine="groovy">
println payload['name']
return payload['name']+'123'
</scripting:script>
</scripting:component>
</flow>
<flow doc:name="httpPost" name="client">
<http:inbound-endpoint doc:name="HTTP" name="httpClient"
exchange-pattern="request-response" host="localhost" path="client"
port="8082" encoding="UTF-8" />
<http:body-to-parameter-map-transformer />
<scripting:component>
<scripting:script engine="groovy">
payload['name'] = 'opasso'
def paramstr = ""
for( param in payload){
paramstr = paramstr + "&" + param.key+ "=" + param.value
}
println "querystr:$paramstr"
return paramstr.substring(1)
</scripting:script>
</scripting:component>
<http:outbound-endpoint address="http://localhost:8082/service"
exchange-pattern="request-response" contentType="application/x-www-form-urlencoded"
method="POST" encoding="UTF-8" />
<!-- This component is just set to show the message accecpted from the request -->
<scripting:component>
<scripting:script engine="groovy">
def msg = "return payload:$payload;".toString()
println msg
return payload
</scripting:script>
</scripting:component>
</flow>
The problem is related to the funky business you're doing in the scripting:component with the streaming message payload generated by the http:outbound-endpoint. The script probably consumes the input stream, leaving it in a state where it can't used anymore.
Try adding a <object-to-string-transformer /> right after the http:outbound-endpoint to deserialize the stream into a string so the payload can be used both in the scripting:component and by Mule.

Request error with WCF Data Services

Its my first time setting up an OData Service and I'm of course having some problems...
The problem is that I can't get the service running, I keep getting an "Request Error".
I have researched on what the problem can be and I found that a common issue is that the access rules are incorrectly typed. So I have tried fixing this both with Singular names, Plural names and I have also tried with typeof(Post).getType().Name
Well here is my code. I hope you can help me, I've been stuck for hours.
public class ODataService : DataService<Entity>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService( DataServiceConfiguration config )
{
//config.SetEntitySetAccessRule( "Users", EntitySetRights.All );
//config.SetEntitySetAccessRule( "Posts", EntitySetRights.All );
//config.SetEntitySetAccessRule( "Albums", EntitySetRights.All );
config.SetEntitySetAccessRule( "*", EntitySetRights.AllRead );
config.SetServiceOperationAccessRule( "*", ServiceOperationRights.AllRead );
//config.SetServiceOperationAccessRule( "GetPosts", ServiceOperationRights.AllRead );
config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
[WebGet]
public IQueryable<Post> GetPosts()
{
return CurrentDataSource.Posts.AsQueryable();
}
}
The structure of my EntityFramework class (db first)
Methods and Members for Entity class. Here the entities are spelled in plural.
This is my Web.config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="Entity" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string="data source=XXX;Initial Catalog=XXX;persist security info=True;user id=XXX;password=XXX;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime requestValidationMode="4.5" targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<pages controlRenderingCompatibilityVersion="4.5" />
<machineKey compatibilityMode="Framework45" />
</system.web>
<system.serviceModel>
<services>
<service name="LinkIT.Core.OData.ODataService" behaviorConfiguration ="DebugEnabled">
</service>
</services>
<behaviors>
<serviceBehaviors >
<behavior name="DebugEnabled">
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
</configuration>
A detailed error message:
The server encountered an error processing the request. The exception
message is 'Value cannot be null. Parameter name:
propertyResourceType'. See server logs for more details. The exception
stack trace is:
at System.Data.Services.WebUtil.CheckArgumentNull[T](T value, String
parameterName) at
System.Data.Services.Providers.ResourceProperty..ctor(String name,
ResourcePropertyKind kind, ResourceType propertyResourceType) at
System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMemberMetadata(ResourceType
resourceType, IProviderMetadata workspace, IDictionary2 knownTypes,
PrimitiveResourceTypeMap primitiveResourceTypeMap) at
System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary2
knownTypes, IDictionary2 childTypes, IDictionary2 entitySets) at
System.Data.Services.Providers.BaseServiceProvider.PopulateMetadata()
at System.Data.Services.Providers.BaseServiceProvider.LoadMetadata()
at
System.Data.Services.DataService1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&
metadataProviderInstance, IDataServiceQueryProvider&
queryProviderInstance, BaseServiceProvider& builtInProvider, Object&
dataSourceInstance) at
System.Data.Services.DataService1.CreateProvider() at
System.Data.Services.DataService1.HandleRequest() at
System.Data.Services.DataService1.ProcessRequestForMessage(Stream
messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] ,
Object[] ) at
System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
instance, Object[] inputs, Object[]& outputs) at
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&
rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet)
WCF Data Services team confirms - this is the exact error faced when you use Enums (which is not yet supported).
Remove the Enum types (or use their suggested work-around and use a wrapper around the enum properties) and this should go away.