Link to home
Start Free TrialLog in
Avatar of HItesh Rana
HItesh Rana

asked on

Call Java Web Service using C#

I'm using C# to call a Java Web Service.  I'm using Visual Studio 2015 The company gave me wsdl file and I generated the proxy class for wse 3.  I don't know WCF so I did it in wse 3

Here is my  app.config file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<configSections>
		<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
	</configSections>
	<microsoft.web.services3>
		<security>
			<binarySecurityTokenManager>
				<add valueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">
					<sessionKeyAlgorithm name="AES128" />
					<keyAlgorithm name="RSAOAEP" />
				</add>
			</binarySecurityTokenManager>
			<x509 storeLocation="CurrentUser" />
			<securityTokenManager>
				<add type="Microsoft.Web.Services3.Security.Tokens.EncryptedKeyTokenManager, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="http://www.w3.org/2001/04/xmlenc#" localName="EncryptedKey">
					<keyAlgorithm name="SHA2" />
				</add>
			</securityTokenManager>
		</security>
		<diagnostics>
			<trace enabled="true" input="InputTrace.webinfo" output="OutputTrace.webinfo" />
			<detailedErrors enabled="true" />
		</diagnostics>
		<policy fileName="wse3policyCache.config" />
		<messaging>
			<mtom clientMode="On" serverMode="always" />
		</messaging>
	</microsoft.web.services3>
	<appSettings>
		<add key="SaveWholeSoapMessage" value="true" />
	</appSettings>
</configuration>

Open in new window


Here is my
wse3policyCache.config file
<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">
	<extensions>
	<extension name="x509" type="Microsoft.Web.Services3.Design.X509TokenProvider, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
	<extension name="mutualCertificate10Security" type="Microsoft.Web.Services3.Design.MutualCertificate10Assertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
	<extension name="TESTPolicyAssertion" type="TESTWS.TESTPolicyAssertion, TESTWS" />
	</extensions>
	<policy name="esar">
	<mutualCertificate10Security establishSecurityContext="false" renewExpiredSecurityContext="false" requireSignatureConfirmation="false" messageProtectionOrder="SignBeforeEncrypt" requireDerivedKeys="false" ttlInSeconds="300">
		<clientToken>
			<x509 storeLocation="CurrentUser" storeName="My" findValue="xxxxxxxx" findType="FindBySubjectName" />
		</clientToken>
		<serviceToken>
			<x509 storeLocation="CurrentUser" storeName="AddressBook" findValue="xxxxxxxxx" findType="FindBySubjectName" />
		</serviceToken>
		<protection>
			<request signatureOptions="IncludeSoapBody" encryptBody="true" />
			<response signatureOptions="IncludeSoapBody" encryptBody="true" />
			<fault signatureOptions="" encryptBody="false" />
		</protection>
	</mutualCertificate10Security>
		<TESTPolicyAssertion/>
	</policy>
</policies>

Open in new window


Part of the payload is an attachment of a text file.  The problem I'm having is that when I turn on mtom (<mtom clientMode="On" serverMode="always" />) I get the following error:
Error: Client found response content type of 'multipart/related; boundary="MIMEBoundary_aecb5c92eb42927b74b62c638a6f50e004008366aba1005a"; type="application/soap+xml"; start="<0.becb5c92eb42927b74b62c638a6f50e004008366aba1005a@apache.org>"; action="http://TEST/Transaction/Submission"', but expected 'application/soap+xml'.

If turn mtom to off I get this error:
<soap:Fault xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><axis2ns1:Code xmlns:axis2ns1="http://www.w3.org/2003/05/soap-envelope"><axis2ns1:Value>env:Sender</axis2ns1:Value></axis2ns1:Code><axis2ns1:Reason xmlns:axis2ns1="http://www.w3.org/2003/05/soap-envelope"><soap:Text xml:lang="en-US">SOAP Body does not contain the CAQH CORE Connectivity Element : Checksum</soap:Text></axis2ns1:Reason></soap:Fault>

So the error above is complaining that I did not attach the file.  I'm assuming.

Not sure how to exactly debug this error.  I'm a bit lost here.  I am able to test the web service using SOAP UI where I'm able to attach the file and everything is working.
SOLUTION
Avatar of Misha
Misha
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HItesh Rana
HItesh Rana

ASKER

@ste5an. What do you mean?  I created the proxy class from the wsdl file I got from the customer.  They don't expose the wsdl file on the web, I only have the wsdl file.  Does that make sense?
@ste5an.  I added the service reference by the file and now I get a 400 bad request error.
That's the problem with separate WSDL files.. they are easily out of sync with the deployed service.
There is no activity from author