How to build a simple web proxy in Mule 3? - mule

I ran this Mule 3 file expecting that when I browse to http://localhost:9000, I would be redirected to http://localhost/path (source - behind a login prompt):
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd">
<pattern:web-service-proxy
name="WSProxyService"
inboundAddress="http://localhost:9000"
outboundAddress="http://localhost/sugarcrm"/>
</mule>
Instead, I get this unfriendly message from the web browser:
‹mO=OÃ0Ýó+ŽL0KÂÈX‚&ˆJ-DÂŒ×øÀ•ì8rÜJý÷8)bb9éî}Ü{â¢y[©Ï®…µÝ#÷ñ´Y¯ ¿F\·ê±QÍ©‹±}Íe&LtV äÓ÷Ѳ¼)+Øú#kè88xˆö$ðf²Øy}šõ•ü‡›®™¥2Ú÷—Î`h·P üõ›Ç{Dë{²ÆO§Ã7…>8Ì¥áÀIÇùOHƒ´

The web-service-proxy pattern is designed to work with SOAP-style web services. Pointing your browser to it won't do you any good.
For pure HTTP proxying either:
use the new pattern:http-proxy coming in Mule 3.2 and already usable in snapshot builds (examples),
use a pattern:bridge with HTTP in and out endpoints (examples).
The former is a much better option, if you're not snapshot averse, as it has extended support for HTTP requests semantics and an upcoming caching module.

I've had a similar problem, although I used soapUI to perform the test. The solution after some days getting lost is simple, configure soapUI not to use/don't allow compression. What you see is actually compressed answer that server did not mark as compressed.

Related

Enable logging in Apache CXF generated client

I followed directions on CXF web site to enable logging of SOAP requests, but cannot see any logging going on in my logs.
I have log4j, so I added -Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger to Tomcat jvm args, then I created cxf.xml and put into classpath. I also added logger into log4j config.
Nothing gets logged.
What can be a problem?
cxf.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
</beans>
I use the LoggingInInterceptor/LoggingOutInterceptor and am not sure about your bus configuration but you should be sure to also added a correct logger (with the correct name) to your log4j configuration.
In the Apache CXF - 2.5 Migration Guido you will find the usefull information
The Logging interceptors now log using service specific
categories/loggers instead of just
LoggingInInterceptor/LoggingOutInterceptor. The names of the logger
that is used is
org.apache.cxf.services.ServiceName.PortName.PortTypeName. This allows
the user to configure specific per service filters and formatters in
their logging configuration.
I have written a blog post about logging with Apache CXF that provides all information I needed to enable request/response logging in my application.

WCF service is not communicating with silverlight4 application on Windows 8. IE 10. IIS 8.0

There are two modules one is silverlight application(like a client) and another one is wcf service which is self hosted service . Here both the application works like client and server communication. Those two applications are communicating properly in windows 7 and previous versions but not in win 8.
There is an error like "
An error occurred while trying to make a request to URI "localhost:8283/MyTestService". This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details."
I tried a many ways which i referred from internet but not able to create connection between them in windows 8.
I tried these ways :
1).added two files clientaccesspolicy.xml and crossdomain.xml to the IIS8(wwwroot) folder as referred by MSN..
2).Giver all permissions to respective folders.
what may be the possible solutions for this ?
1). any security issues might be there
2). windows 8 is enterprise edition
If any more details required let me know in comments.
I am looking forward for your respond..
After so much of R&D , i got the solution to work silverlight and WCF service in windows 8 environment. I am answering to my question if it may helpful to anybody caught in this type of error ..
Actual Cause :
No communication is creating in between CVT Service(WCF service) and CVT pages(silver light application) as client side. Whenever it compiled in windows 8 environment . Then the error caught was “ An error occurred while trying to make a request to URI ‘http://localhost:8283. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. Please see the inner exception for more details. “.
Resolution :
The actual problem is present in WCF service . Below steps to be followed to run the WCF service successfully and make it communicate properly with silver light application in windows 8 environment. In windows 7 and previous versions the settings related to WCF service work will be enabled by default but in win 8 few features might not be enabled in that case you can follow these below steps.
step 1 :
create and add two XML files to wwwroot folder. This folder is located in this path “C:\inetpub\wwwroot”.
a). clientaccesspolicy.xml :
<xml version="1.0" encoding="utf-8">
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
</xml>
b). crossdomain.xml :
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain- policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
Step 2 : If this feature is not activated , enable this feature by following the below steps.
Hit Windows+x.
Select Programs and Features(first item on list).
Select Turn Windows Features on or off on the left.
Expand .Net Framework 4.5 Advanced Services.
Expand WCF services.
Enable HTTP Activation.
Step 3 : Adding MIME Type and new managed handler
WCF services don’t run on IIS 8 with the default configuration, because the web server doesn’t know, how to handle incoming requests targeting .svc files. You can teach it in two steps:
Refer below link :
https://gyorgybalassy.wordpress.com/2012/09/24/
Step 4 : Application should be compiled in windows 8 environment .
We need to follow these steps to run this application in windows 8 environment.

Could not find endpoint element in .Config File

Good day to all,
We've encountered some configuration problem while retrieving an end point from configuration file at creating a ChannelFactory object.
Could not find endpoint element with name 'no matter service'
and contract 'no matter contract' in the ServiceModel client configuration section. This might be
because no configuration file was found for your application, or
because no endpoint element matching this name could be found in the
client element.
The usual solution at this kind of exception is to add .config file to exe that runs this code.
In this case we're running this code at com+ so i'd created dllhost.exe.config file with all the endpoints.
The intresting thing is that i'm using this service also from a client application and there my wcf platform founds the same endpoint without any problem.
Other endpoints at dllhost.exe.config working fine i think.
By the way the problematic proxy that uses this service is customised Enterprise Library code.
While debugging the code it is defenetly runs under the dllhost process.
Is there some way to find out it what config file it looks for the endpoint?
Thank you.
Well, after a few days of checking and testing we'd found out 2 ways to solve the problem:
dllhost.exe.config - should not be edited/created/updated manually,but from MSI.Probably the reason is that is is placed at system32 directory and windows blocks it.
Better way - is to create for COM+ Service Application Root Directory and place there 2 files
ServiceName.config - Contains list of endpoints
ServiceName.manifest - Contains 3 rows
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
</assembly>

"Content is not allowed in prolog" error for Mule Core Schema

While running my mule configuration file, I am getting SAXParserException "Content is not allowed in prolog" in the line:
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
......
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
.......
</mule>
When I open http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd in browser, it shows this warning message before the starting of the XSD file:
Warning: fopen(./logs/proxy-2012-09.log): failed to open stream: Permission denied in /var/www/domains/mulesoft.org/mule/drupal/drupal-6.25/mule-schema/proxy.php on line 56
and some more warnings.
Can somebody suggest any solution? Thanks in advance.
There have been some outage during the weekend with MuleSoft's servers hosting the XSDs.
However the resolution of the schema through the web is only a fallback and no application should rely on it.
To make sure that the schema are retrieved from the jars and not from the internet you need to the the schema version (e.g. 3.0 ) to the same version of the jars included in your classpath.
If you are using mule >= 3.2 it is recommended to use the current version.

SOAP request is not correct while sending to SAP PI

I'm consuming a SAP PI Web Service and some reason it's not working. I'm thinking due to incorrect SOAP XML below:
This is what SAP PI is expecting:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:A_Request xmlns:ns0="http://domain.co.au/abc">
<Root>
<Element1>a</Element1>
<Element1>a</Element1>
</Recordset>
</ns0:A_Request>
This is what I'm sending:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<A_Request xmlns="http://domain.co.au/abc" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Root>
<Element1>a</Element1>
<Element1>a</Element1>
</Recordset>
</A_Request>
Is there any way (programatically or config) that can be done on client side in order to format the XML request as expected by Server?
Or, the it should be fixed in WSDL and client program (my program) will automatically generate the required xml?
Thank you heaps.
You should not manually generate or format the XML sent to the server from the client side. If the server exposes a valid SOAP based service simply point the client to the WSDL and it will generate strongly typed classes that you can use to consume the service. If you are using .NET 3.0 or higher on the client it is recommended that you use the svcutil.exe (or Add Service Reference in VS) to generate those classes. If you are using an older version you could use wsdl.exe (or Add Web Reference in VS).