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.
LVL 1
HItesh RanaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MishaProgrammerCommented:
Lock this article. May be it can help you
Webservice from c#
0
ste5anSenior DeveloperCommented:
You need to add a Service Reference in your project. See How to: Add, Update, or Remove a Service Reference.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HItesh RanaAuthor Commented:
@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?
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

HItesh RanaAuthor Commented:
@ste5an.  I added the service reference by the file and now I get a 400 bad request error.
0
ste5anSenior DeveloperCommented:
That's the problem with separate WSDL files.. they are easily out of sync with the deployed service.
0
MishaProgrammerCommented:
There is no activity from author
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.