Mule Facebook Null Payload - facebook

Asked to evaluate buying Mulesoft - and produce demo that connects to facebook. Am following the two samples here:
https://github.com/mulesoft/facebook-connector/blob/master/doc/sample.md
and
http://blogs.mulesoft.com/mule-school-integration-with-social-media-part-ii-%E2%80%93-facebook/
Ran into a problem with the first sample - it wouldn't compile because the endpoint for the http connector was the same as the facebook connector. I did some research and made some changes, but I now get the error below and can't find anyone else that experienced the same:
Unable to fetch access token. Message payload is of type: NullPayload - this is on the callback page. Has anyone experienced this?
Here is my code:
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8099" doc:name="HTTP Listener Configuration"/>
<facebook:config-with-oauth name="Facebook-config" consumerKey="..." consumerSecret="..." scope="user_photos" doc:name="Facebook">
<facebook:oauth-callback-config domain="localhost" localPort="8099" remotePort="8099" path="callback"/>
</facebook:config-with-oauth>
<http:listener-config name="HTTP_Listener_Configuration1" host="localhost" port="8094" doc:name="HTTP Listener Configuration"/>
<flow name="Authorize">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<facebook:authorize config-ref="Facebook-config" doc:name="Facebook"/>
<set-session-variable variableName="accessTokenID" value="#[flowVars['OAuthAccessTokenId']]" doc:name="Save Access Token"/>
<flow-ref name="PhotoDownload" doc:name="Call Photo Download"/>
</flow>
<flow name="PhotoDownload">
<http:listener config-ref="HTTP_Listener_Configuration1" path="/" doc:name="HTTP"/>
<not-filter doc:name="Not">
<wildcard-filter pattern="/favicon.ico" caseSensitive="false"/>
</not-filter>
<facebook:get-user-picture config-ref="Facebook-config" user="me" accessTokenId="#[sessionVars['accessTokenId']]" doc:name="Get Profile Picture"/>
<file:outbound-endpoint path="c:\temp" outputPattern="profilepic.jpg" responseTimeout="10000" doc:name="Save The Picture "/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
Here is the stack trace:
ERROR 2015-06-10 13:47:07,731 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule exception DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Unable to fetch access token. Message payload is of type: NullPayload
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. unable to find valid certification path to requested target (sun.security.provider.certpath.SunCertPathBuilderException)
sun.security.provider.certpath SunCertPathBuilder:-1 (null)
2. PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (sun.security.validator ValidatorException)
sun.security.validator PKIXValidator:-1 (null)
3. sun.security.validator ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (javax net ssl SSLHandshakeException)
sun security ssl Alerts:-1 ( java.sun com/j2ee/sdk_1.3/techdocs/api/javax/net/ssl/SSLHandshakeException html)
4. Error found while consuming http resource at https(colonslashslash) graph facebook com/oauth/access_token (java.lang.RuntimeException)
org.mule security oauth util HttpUtilImpl:93 (null)
5. Unable to fetch access token. Message payload is of type: NullPayload (org mule api MessagingException)
org.mule.security.oauth.processor.OAuth2FetchAccessTokenMessageProcessor:95 ( wwwmulesoftrog docs site current3 apidocs org mule api MessagingException html)
--------------------------------------------------------------------------------
Root Exception stack trace:
sun.security.provider certpath SunCertPathBuilderException: unable to find valid certification path to requested target
at sun security provider certpath SunCertPathBuilder engineBuild(Unknown Source)
at java.security cert CertPathBuilder build(Unknown Source)
at sun.security validator PKIXValidator doBuild(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
INFO 2015-06-10 13:47:08,183 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule module http internal listener HttpListenerRegistry: No listener found for request: (GET)/favicon ico
INFO 2015-06-10 13:47:08,184 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule module http internal listener HttpListenerRegistry: Available listeners are: [(*)/callback/, (*)/]

Couple things might help. First off, make sure your FB App and Mule FB Config match on the "scope" Ex. "email,public_profile,user_friends".
Also, I solved part of this issue by creating a global HTTP element as the callback. The callback HTTP path needs to be "/*". Then in the Authorization FB component under the OAuth tab, I put the callback HTTP name as the HTTP Connector Reference.
<facebook:oauth-callback-config domain="localhost"
localPort="5000" remotePort="5000" connector-ref="callback"></facebook:oauth-callback-config>
</facebook:config-with-oauth>
<http:listener-config name="callback" host="0.0.0.0"
port="5000" basePath="/*" doc:name="HTTP Listener Configuration" />

Related

SP Metadata. WantAssertionsSigned false or true?

I am the SP. I am trying to help the IdP to send me (Unsolicited SSO) SAML assertions appropriately. But What happens is that SAML comes without signature.
In my logs, after callback phase initiates it raises an ERROR message:
ERROR -- omniauth: (saml_degreed) Authentication failure! invalid_ticket: OneLogin::RubySaml::ValidationError, Found an unexpected number of Signature Element. SAML Response rejected
When I copy his SAML message from terminal and 64base decode it, what I see is a jump from element <saml:Issuer> to element <saml:Subject>. There is no <Signature> element.
When I tell him there is no <Signature> element in the message I receive, he sends me (By email) the message he is supposedly sending, with <Signature> element.
Is there something from my side (SP) to be done ? Find below my metadata file. I have already tried to change WantAssertionsSigned to "true" as well as AuthnRequestsSigned, but still failed.
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
cacheDuration="PT604800S"
entityID="https://qa.mypage.com">
<md:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</md:NameIDFormat>
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="https://qa.mypage.com/students/auth/saml_test/callback"
index="1" />
</md:SPSSODescriptor>
</md:EntityDescriptor>

Mule: how to consume a service from a remote client

I have been following this tutorial which is really great to consume wb services from WSDL http://training.middlewareschool.com/mule/consuming-wsdl-first-service/.
I have been trying to do a similar approach by generating a client web service in Eclipse using CXF and publishing the web service in Mule. My question is: if I configure for the client and mule application to have the same endpoint (for example: localhost:8082/ipsoap/test), how can I have the web service work the same way as with the tutorial.
Meaning if I test sending a request to mule from the client (in eclipse) I should receive the right response from mule. Thank you in advance for your time.
So in short:
1-I generated a client app in eclipse using the wsdl in the following link in the tutorial: http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl
2- As a start in Mule, I added an http connector and a logger and changed the endpoint path in eclipse to the one I set on the HTTP connector on Mule. Thus, I can see that there is a payload when I am sending a request to Mule from the client in Eclipse.
3- I need to have an application, namely my client app in eclipse, consume a published service in Mule. Now I think this is achieved using the CXF component but I still fail to make it work. In fact, I wonder if this is one valid way of using Mule since I couldn't find any tutorial about what I am trying to achieve.
So here is how I test it:
I used the same endpoint I used in Mule and receive the following log:
> INFO 2014-07-07 13:19:46,124
> [[soapservice].connector.http.mule.default.receiver.02]
> org.mule.api.processor.LoggerMessageProcessor: message transformation
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:q0="http://ws.cdyne.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Body>
> <q0:ResolveIP>
> <q0:ipAddress>173.194.36.39</q0:ipAddress>
> <q0:licenseKey/>
> </q0:ResolveIP> </soapenv:Body> </soapenv:Envelope>
>
> ERROR 2014-07-07 13:19:46,134
> [[soapservice].connector.http.mule.default.receiver.02]
> org.mule.exception.DefaultMessagingExceptionStrategy:
> ******************************************************************************** Message : wrong number of arguments. Failed to route
> event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor.
> Message payload is of type: String Code :
> MULE_ERROR--2
> -------------------------------------------------------------------------------- Exception stack is:
> 1. wrong number of arguments (java.lang.IllegalArgumentException) sun.reflect.NativeMethodAccessorImpl:-2 (null)
> 2. wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
> type: String (org.mule.api.transport.DispatchException)
> org.mule.module.cxf.CxfOutboundMessageProcessor:150
> (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
> -------------------------------------------------------------------------------- Root Exception stack trace: java.lang.IllegalArgumentException: wrong
> number of arguments at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
As you can see the soap request can be seen but it is not consumed at the level of the CXF component. Here is my mule code:
<flow name="SoapService" doc:name="SoapService">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="test/cap.asmx" doc:name="HTTP"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<logger message="message transformation #[message.payload]" level="INFO" doc:name="Logger"/>
<flow-ref name="RequestResponse" doc:name="Flow Reference"/>
<logger level="INFO" doc:name="Logger" message="after posting #[message.payload]"/>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
</flow>
<flow name="RequestResponse" doc:name="RequestResponse">
<cxf:jaxws-client operation="ResolveIP" clientClass="pck.IP2Geo" port="IP2GeoSoap" wsdlLocation="file:/C:/Users/12204-hajjam1/workspace/ipgo/src/ipgeo.wsdl" doc:name="soap 2"/>
<logger message="before posting #[message.payload]" level="INFO" doc:name="Logger"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:10387/ip2geo/ip2geo.asmx" doc:name="HTTP"/>
</flow>
Also if I add a set payload with the ip #[{'173.194.36.39',''}] (the second argument can be left empty) before the cxf component it returns a an empty element. Yet, the response should be something like this:
<pck.IPInformation>
<city>Mountain View</city>
<stateProvince>CA</stateProvince>
<country>United States</country>
<organization/>
<latitude>37.4192</latitude>
<longitude>-122.0574</longitude>
<areaCode>0</areaCode>
<timeZone/>
<hasDaylightSavings>false</hasDaylightSavings>
<certainty>90</certainty>
<regionName/>
<countryCode>US</countryCode>
</pck.IPInformation>
Thus, my problem is with the consumption and retrieval of the response.
I apologize for the length but I have been struggling with this and haven't found a solution online. Thanks in advance.
You should create an instance of the message class that as been generated for the ResolveIP method from the WSDL and use it as the message payload before the cxf:jaxws-client element.

How to forward SOAP request through ACTIVE MQ JMS to my Services with the support of MULE

We have produced JAX-WS web-services with the help of Java API and published. Now we would like to queuing the requests, which are coming for the services with the help of JMS. We chosen the ACTIVE MQ JMS Server with the combination of MULE ESB.
We have tried the proxying of webservices with the help of two Http Endpoints. It is working fine. So When i trying to test it by sending request from SOAP UI to Http inbound end point, it is forwarding request to my services and get back the response to SOAP UI.
But when we are trying to put the JMS endpoint in between these Http end points, the request is forwarded to my services, but not the message (SOAP).
Please help me to resolve the issue or suggest me the alternative way for Queuing.
Following image shows flow in MULE.
.
Following is the flow :
<jms:activemq-connector name="Active_MQ1" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="finalFlow1" doc:name="finalFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8888" contentType="text/xml" doc:name="HTTP"/>
<jms:outbound-endpoint exchange-pattern="request-response" queue="servicesQueue" connector-ref="Active_MQ1" doc:name="JMS"/>
<http:outbound-endpoint mimeType="text/xml" doc:name="HTTP" exchange-pattern="request-response" method="POST" path="MyServices" host="localhost" port="5050" />
</flow>
Actually MyServices is produced at http://localhost:5050/MyServices
The problem is probably due to that you are expecting a string payload in your JMS queue and the http:inbound-endpoint produces a stream payload.
Try putting <object-to-string-transformer/> before the jms:outbound-endpoint.

Getting error while envoking rest API URL

I have created an API in wso2 ESB as:
<api xmlns="http://ws.apache.org/ns/synapse" name="getUUIDAPI" context="/getUUID">
<resource methods="GET" uri-template="?Name={searchValue}" inSequence="getUUIDIN" outSequence="CommonJsonOut"/>
</api>
and it gives me an API Invocation URL as http://10.224.64.97:8280/getUUID. Now when i try this rest service in my browser as :
http://10.224.64.97:8280/getUUID?Name=uvu
, In the esb i get error as :
TID: [0] [ESB] [2013-06-26 10:25:50,796] ERROR {org.apache.axis2.description.ClientUtils} - The system cannot infer the transport information from the
/getUUID?Name=uvu?Name=uvu URL. {org.apache.axis2.description.ClientUtils}
TID: [0] [ESB] [2013-06-26 10:25:50,796] ERROR {org.apache.synapse.core.axis2.Axis2Sender} - Unexpected error during sending message out {org.apache.synapse.core.axis2.Axis2Sender}
org.apache.axis2.AxisFault: The system cannot infer the transport information from the /getUUID?Name=uvu?Name=uvu URL.
at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:81)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:115)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:456)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:57)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:316)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:329)
at org.apache.synapse.endpoints.WSDLEndpoint.send(WSDLEndpoint.java:69)
at org.apache.synapse.endpoints.IndirectEndpoint.send(IndirectEndpoint.java:54)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:95)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
at org.apache.synapse.rest.Resource.process(Resource.java:306)
at org.apache.synapse.rest.API.process(API.java:308)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:76)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:63)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:182)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:83)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:367)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:204)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
As you can see in the above error the url it is hitting is /getUUID?Name=uvu?Name=uvu but i am sending /getUUID?Name=uvu.
Why i am getting this strange error? If i copy the api file, sequences associated with api to other server's esb and then i hit with above url i get the response.
Please help me on this. Thanks in advance
define something like this;
uri-template="/{searchValue}"

Consuming secured WCF service through basicHTTPbinding

I am consuming an secured service hosted over basicHttpBinding
I have to pass credentials to the service for authenticatioon
Here’s the config setting for the client
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
While calling the service, I am getting following exception message
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
Message = "An invalid security token was provided (Bad UsernameToken Values)”
I not sure how to get it working I am curious if somebody can help me out or provide me any url where I could find the solution
When you create your MyServiceClient object you can set the username and password on the clientInstance.Credentials.UserName object.