I'm trying to use choice flow control to route SOAP web service, it depends on payload to change to matching web-service. Here is my flow
<flow name="ProxyServiceFlow1" doc:name="ProxyServiceFlow1">
<http:inbound-endpoint exchange-pattern="request-response"
address="http://localhost:8081/hrManagerServiceProxy" doc:name="HTTP" />
<set-variable variableName="clientType"
value="#[message.inboundProperties['http.query.params']['clientType']]"
doc:name="Set clientType" />
<choice doc:name="Choice">
<when expression="#[clientType == 'unsecure']">
<cxf:proxy-service namespace="http://service.freetalk.viettel.com/"
service="RegisterServiceService" payload="body" wsdlLocation="unsecure.wsdl"
enableMuleSoapHeaders="false" doc:name="SOAP" />
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8081/HR/hrManagerService" doc:name="HTTP"/>
</when>
<otherwise>
<cxf:proxy-service namespace="http://service.freetalk.viettel.com/"
service="RegisterServiceService" payload="body" wsdlLocation="unsecure2.wsdl"
enableMuleSoapHeaders="false" doc:name="SOAP" />
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8081/HR/hrManagerService" doc:name="HTTP"/>
</otherwise>
</choice>
</flow>
It's just my thought, because I google many times but still get no result. Someone please give me some advises.
Its not the cxf:proxy-service that needs to be used along with the HTTP Outbound.
It should be cxf:proxy-client
Try using cxf:proxy-client with your http:outbound-endpoint.
<choice doc:name="Choice">
<when expression="#[clientType == 'unsecure']">
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8081/HR/hrManagerService" doc:name="HTTP">
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true">
</cxf:proxy-client>
</http:outbound-endpoint>
</when>
<otherwise>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8081/HR/hrManagerService" doc:name="HTTP">
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true">
</cxf:proxy-client>
</http:outbound-endpoint>
</otherwise>
</choice>
Hope this helps.
Related
I am trying to sign in to Tomcat manager and host-manager webapps which I have hosted on Amazon Web Service.
Even after entering the correct password in the popup, the pop up keeps showing and if I cancel it, then I am redirected to 401 error page
I have updated /etc/tomcat8/tomcat-users.xml correctly.
It stopped working after I added <Context path="" docBase="mywebapp" debug="0" privileged="true" /> inside server.xml
/etc/tomcat8/tomcat-users.xml
<role rolename="manager-gui"/>
<user username="supermanager" password="superpassword" roles="manager-gui" />
<role rolename="admin-gui"/>
<user username="superadmin" password="superpassword" roles="admin-gui"/>
</tomcat-users>
server.xml
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" proxyPort="80" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="MYDOMAIN.COM">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="MYDOMAIN.COM" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="mywebapp" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
/etc/tomcat8/Catalina/localhost/manager.xml(host-manager.xml)
/etc/tomcat8/Catalina/MYDOMAIN.COM/manager.xml(host-manager.xml)
<Context path="/manager"
docBase="/usr/share/tomcat8-admin/manager"
antiResourceLocking="false" privileged="true" />
All I did was tried to login using Google Chrome instead of Firefox and VOILA!
It worked!!!
I was using the following configuration to hit a SOAP based service in mule 3.2, which works fine
<https:connector name="https" doc:name="HTTP\HTTPS"></https:connector>
<https:outbound-endpoint exchange-pattern="request-response" method="POST"
address="https://localhost:8080/CXF3Service/test" responseTimeout="15000" contentType="application/xml"
doc:name="HTTP Submit Request SOAP" connector-ref="https"> <message-properties-transformer
scope="outbound"> <add-message-property key="SOAPAction" value="https://myservice/myEndpoint"
/> </message-properties-transformer> </https:outbound-endpoint>
SOAP Binding in wsdl will look like,
<wsdl:operation name="sayHello">
<soap:operation soapAction="https://myservice/myEndpoint" style="document"/>
<wsdl:input name="sayHello">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
On migrating to Mule 3.6, i replaced the code as follows. this was done to replace the deprecated https:outbound-endpoint with http:request
<http:request-config name="http" protocol="HTTPS"
host="localhost" port="8080"
doc:name="HTTP Request Configuration"/>
<http:request config-ref="http" path="CXF3Service/test" method="POST"
doc:name="HTTP" responseTimeout="15000" >
<http:request-builder>
<http:header headerName="SOAPAction" value="https://myservice/myEndpoint" ></http:header>
</http:request-builder>
<http:success-status-code-validator
values="0..599" />
</http:request>
But on hitting the service with new code, i am getting a SOAP Fault as response.
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server did not recognize the value of HTTP Header SOAPAction: https://myservice/myEndpoint, "".</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What could be the possible reason for this?
FYI. I am using a cxf:proxy-client with payload as envelope, which remains unchanged for both.
<cxf:proxy-client payload="envelope" doc:name="Proxy client">
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:inInterceptors>
<cxf:outInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:outFaultInterceptors>
</cxf:proxy-client>
Small tweak did the magic!!
I set the SOAPAction before the http:request instead of setting it inside.
<cxf:proxy-client payload="envelope" doc:name="Proxy client">
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:inInterceptors>
<cxf:outInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:outFaultInterceptors>
</cxf:proxy-client>
<message-properties-transformer>
<add-message-property key="SOAPAction" value="https://myservice/myEndpoint"/>
</message-properties-transformer>
<http:request config-ref="http" path="CXF3Service/test" method="POST"
doc:name="HTTP" responseTimeout="15000" >
<http:success-status-code-validator
values="0..599" />
</http:request>
I created a WCF service and hosted it on my IIS server. Then, I needed to edit the schemaLocation. I followed this post.
When I add "?wsdl" to the url, I get an empty page. If I try to use the WSDL from SOAPui to test it, I get this "Error loading [http://xx.xxx.xx.xx:8095/CardServiceLib.CardService.svc/service?wsdl]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after nul"
If I delete the HTTPGetUrl, the WSDL is correct but the schemaLocation isn't what I want. With the mod I made with the linked post, the schemaLocation is perfect but the WSDL is empty... why?
This works, but not as I want (generates WSDL but with wrong links):
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
and this not (doesn't generate WSDL --> blank page!!!):
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" httpGetUrl="http://xx.xx.xx.xx.:8095/MyService.svc/endpoint"/>
This is my web.config on IIS server 7
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="connectionString" connectionString="server=xxxxx;database=xxxxx;uid=xxxxx;pwd=xxxxx;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="userName" value="admin" />
<add key="password" value="xxxxx" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
<add key="SecurityKey" value="xxxxxxxxxx" />
</appSettings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<!--<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>-->
</system.web>
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<!-- the "" standard endpoint is used for auto creating a web endpoint. -->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<basicHttpBinding>
<binding name="SecurityByTransport" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
<!--<message clientCredentialType="UserName"/>-->
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="CardServiceLib.CardService" behaviorConfiguration="customBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="SecurityByTransport" name="base" contract="CardServiceLib.ICardService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
<!--<endpoint address="web" behaviorConfiguration="webHttp" binding="webHttpBinding"
bindingConfiguration="" name="web" contract="calc.ICalcService">
<identity>
<dns value="localhost" />httpGetUrl="http://77.108.40.77:8095/CardServiceLib.CardService.svc/service"
</identity>
</endpoint>-->
<host>
<baseAddresses>
<add baseAddress="https://xx.xx.xx.xx:8095/MyService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
<behavior name="customBehavior">
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" httpGetUrl="http://xx.xx.xx.xx:8095/MyService.Service.svc/service"/>
<serviceDebug includeExceptionDetailInFaults="True" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="xx,xx" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="webHttpBinding" scheme="http" />
</protocolMapping>-->
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="false" />
</system.webServer>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup></configuration>
SOLVED!! I added this
address="http://192.168.1.2/Demo.Service/MultiEndPointsService.svc/basic"
in my endpoint tag, like written in this link.
I suspect the issue is related to the authentication required to access the WSDL.
When attempting to access the metadata URL directly, the web site indicates the following:
“Authentication Required”
“The server http://...:8095 requires a username and password.”
You either need to provide the proper credentials or relax the permissions on the WSDL.
I have a SOAP webservice as follow :-
<spring:bean id="cacheManager" name="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
<spring:bean id="cache" name="cache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<spring:property name="cacheManager" ref="cacheManager"/>
<spring:property name="cacheName" value="dbCache"/>
<spring:property name="maxElementsInMemory" value="10000"/>
<spring:property name="eternal" value="false"/>
<spring:property name="timeToIdle" value="${timeToIdle}"/>
<spring:property name="timeToLive" value="${timeToLive}"/>
<spring:property name="overflowToDisk" value="true"/>
<spring:property name="maxElementsOnDisk" value="10000000"/>
<spring:property name="diskPersistent" value="false"/>
<spring:property name="diskExpiryThreadIntervalSeconds" value="5"/>
<spring:property name="memoryStoreEvictionPolicy" value="LRU"/>
<!-- Cache Expiry -->
</spring:bean>
</spring:beans>
<ee:object-store-caching-strategy name="cachingStrategy" doc:name="cachingStrategy">
<custom-object-store class="com.anirban.EHCatche.EhcacheObjectStore">
<spring:property name="cache" ref="cache"/>
</custom-object-store>
</ee:object-store-caching-strategy>
<!-- Catch Strategy ends -->
<flow name="ServiceFlow" doc:name="ServiceFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP" />
<ee:cache doc:name="Cache" cachingStrategy-ref="cachingStrategy">
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" doc:name="SOAP"/>
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl"/>
</ee:cache>
</flow>
Now as you can see .. I have wrapped the cxf:jaxws-service and component class under ee:cache block ..
The Webservice fetch a set of Data from DB
My main intention is if I trigger the webservice ,it will fetch the Data from DB from the first time and then for the same request it will fetch from cache for a particular time ... In between if I trigger the service with different request it will again fetch data from DB for the first time for that request and then retrieve from the cache for the subsequent same request ..
It will hold the data in cache for a particular time ..
Now the issue is If I trigger the service .. it's always fetching the Data from DB and it's not holding any data in cache for the same request ..
Every time I hit the service it hits the Database directly and the data is not fetched from cache for the same request ..
Please help .. how to configure the cache with CXF in Mule
Break your service flow in two, using a VM endpoint and serializing both the request and response to string. This will make the event cacheable.
<flow name="ServiceFlow" doc:name="ServiceFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP" />
<object-to-string-transformer />
<ee:cache doc:name="Cache" cachingStrategy-ref="cachingStrategy">
<vm:outbound-endpoint path="cxf.service" exchange-pattern="request-response" />
<object-to-string-transformer />
</ee:cache>
</flow>
<flow name="CXFFlow" doc:name="CXFFlow">
<vm:inbound-endpoint path="cxf.service" exchange-pattern="request-response" />
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" doc:name="SOAP"/>
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl"/>
</flow>
So, the final solution is as David suggested, by breaking the flow into two and also using <object-to-string-transformer /> for serializing both the request and response which is very important for a Cache to perform
I'm new to Mule ESB and am trying to figure out how I can debug mule flows when running them from a FunctionalTestCase test class.
Using the visual debugger in Mule Studio works fine when running as a Mule Application, but not when running in a Junit test.
Is there any way to debug a flow that is run from a test? As an example, is there any way to step through TestFlow1 in a test method of a FunctionalTestCase if configured as below?
<flow name="TestFlow1" doc:name="TestFlow1">
<vm:inbound-endpoint exchange-pattern="one-way"
doc:name="VM" path="testIn" />
<choice doc:name="Choice">
<when expression="payload == 'Foo'">
<logger message="Got Foo!" level="INFO" doc:name="Logger"/>
<vm:outbound-endpoint exchange-pattern="one-way" path="testOut0" doc:name="VM"/>
</when>
<otherwise>
<logger message="Got [#payload]!" level="INFO" doc:name="Logger"/>
<vm:outbound-endpoint exchange-pattern="one-way" path="testOut1" doc:name="VM"/>
</otherwise>
</choice>
</flow>
<flow name="TestFlow2" doc:name="TestFlow2">
<vm:inbound-endpoint exchange-pattern="one-way" path="testOut0" doc:name="VM"/>
<test:component />
</flow>
<flow name="TestFlow3" doc:name="TestFlow3">
<vm:inbound-endpoint exchange-pattern="one-way" path="testOut1" doc:name="VM"/>
<test:component />
</flow>
Unfortunately, this is a known issue.
Please upvote the issue and watch it.