Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java webservice requires usernametoken over basichttpbinding

336 views
Skip to first unread message

Kai Fransson

unread,
Feb 17, 2010, 10:24:01 AM2/17/10
to
I need to call a Java webservice. I can add a service reference without
problems, and I get Intellisense in Visual Studio. However, when I try to
call a service method I get an error message saying "Missing (user) Security
Information".

I n my code I try to set usercredentials:
testWS.WarrantyClaimServiceClient svc = new
TestClient.testWS.WarrantyClaimServiceClient();

svc.ClientCredentials.UserName.UserName = "myusername";
svc.ClientCredentials.UserName.Password = "mypswd";

The WSDL of the service looks like this:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tns="http://www.scan.com/sgws"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.scan.com/sgws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema elementFormDefault="qualified"
targetNamespace="http://www.scan.com/sgws">
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd0.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd1.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd2.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd3.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd4.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd5.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd6.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd7.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd8.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd9.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd10.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd11.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd12.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd13.xsd" />
<xs:include schemaLocation="WarrantyClaimService?xsd=xsd14.xsd" />
</xs:schema>
</wsdl:types>
<wsdl:message name="requestPartOut">
<wsdl:part name="parameters" element="tns:partReqR" />
</wsdl:message>
<wsdl:message name="epsIn">
<wsdl:part name="parameters" element="tns:epsReq" />
</wsdl:message>
<wsdl:message name="confirmWarrantyApplianceIn">
<wsdl:part name="parameters" element="tns:confirmW" />
</wsdl:message>
<wsdl:message name="claimHistoryOut">
<wsdl:part name="parameters" element="tns:claimHistR" />
</wsdl:message>
<wsdl:message name="FaultMessage">
<wsdl:part name="parameters" element="tns:errorMessage" />
</wsdl:message>
<wsdl:message name="claimHistoryIn">
<wsdl:part name="parameters" element="tns:claimHist" />
</wsdl:message>
<wsdl:message name="claimRequestOut">
<wsdl:part name="parameters" element="tns:claimR" />
</wsdl:message>
<wsdl:message name="confirmWarrantyApplianceOut">
<wsdl:part name="parameters" element="tns:confirmWR" />
</wsdl:message>
<wsdl:message name="claimStatusOut">
<wsdl:part name="parameters" element="tns:claimStatusR" />
</wsdl:message>
<wsdl:message name="campaignIn">
<wsdl:part name="parameters" element="tns:camp" />
</wsdl:message>
<wsdl:message name="claimRequestIn">
<wsdl:part name="parameters" element="tns:claim" />
</wsdl:message>
<wsdl:message name="epsOut">
<wsdl:part name="parameters" element="tns:epsReqR" />
</wsdl:message>
<wsdl:message name="claimStatusIn">
<wsdl:part name="parameters" element="tns:claimStatus" />
</wsdl:message>
<wsdl:message name="campaignOut">
<wsdl:part name="parameters" element="tns:campR" />
</wsdl:message>
<wsdl:message name="requestPartIn">
<wsdl:part name="parameters" element="tns:partReq" />
</wsdl:message>
<wsdl:portType name="WarrantyClaimService">
<wsdl:operation name="requestPart">
<wsdl:documentation>
Returns information about Factory or Distributor requested parts.
</wsdl:documentation>
<wsdl:input message="tns:requestPartIn" />
<wsdl:output message="tns:requestPartOut" />
<wsdl:fault name="requestPartFault" message="tns:FaultMessage" />
</wsdl:operation>
<wsdl:operation name="confirmWarrantyAppliance">
<wsdl:documentation>
Checks whether a warranty applies to a truck, bus or engine.
</wsdl:documentation>
<wsdl:input message="tns:confirmWarrantyApplianceIn" />
<wsdl:output message="tns:confirmWarrantyApplianceOut" />
<wsdl:fault name="confirmWarrantyApplianceFault"
message="tns:FaultMessage" />
</wsdl:operation>
<wsdl:operation name="claimRequest">
<wsdl:documentation>
Submitting and assessment of a claim.
</wsdl:documentation>
<wsdl:input message="tns:claimRequestIn" />
<wsdl:output message="tns:claimRequestOut" />
<wsdl:fault name="claimRequestFault" message="tns:FaultMessage" />
</wsdl:operation>
<wsdl:operation name="claimStatus">
<wsdl:documentation>
Returns requested information about existing warranty claims
</wsdl:documentation>
<wsdl:input message="tns:claimStatusIn" />
<wsdl:output message="tns:claimStatusOut" />
<wsdl:fault name="claimStatusFault" message="tns:FaultMessage" />
</wsdl:operation>
<wsdl:operation name="claimHistory">
<wsdl:documentation>
Returns history information about warranty claim.
</wsdl:documentation>
<wsdl:input message="tns:claimHistoryIn" />
<wsdl:output message="tns:claimHistoryOut" />
<wsdl:fault name="claimHistoryFault" message="tns:FaultMessage" />
</wsdl:operation>
<wsdl:operation name="eps">
<wsdl:documentation>
Returns information about valid EPS.
</wsdl:documentation>
<wsdl:input message="tns:epsIn" />
<wsdl:output message="tns:epsOut" />
<wsdl:fault name="epsFault" message="tns:FaultMessage" />
</wsdl:operation>
<wsdl:operation name="campaign">
<wsdl:documentation>
Returns information about warranty campaigns.
</wsdl:documentation>
<wsdl:input message="tns:campaignIn" />
<wsdl:output message="tns:campaignOut" />
<wsdl:fault name="campaignFault" message="tns:FaultMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WarrantyClaimServiceSoap"
type="tns:WarrantyClaimService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="requestPart">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="requestPartFault">
<soap:body use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="confirmWarrantyAppliance">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="confirmWarrantyApplianceFault">
<soap:body use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="claimRequest">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="claimRequestFault">
<soap:body use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="claimStatus">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="claimStatusFault">
<soap:body use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="claimHistory">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="claimHistoryFault">
<soap:body use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="eps">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="epsFault">
<soap:body use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="campaign">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="campaignFault">
<soap:body use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WarrantyClaimService">
<wsdl:documentation>
The WarrantyClaimService Web Service is responsible for offering
operation needed to support online registration and validation of Warranty
Claims
</wsdl:documentation>
<wsdl:port name="WarrantyClaimServiceSoap"
binding="tns:WarrantyClaimServiceSoap">
<soap:address
location="http://10.0.1.37:8080/axis2/services/WarrantyClaimService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


My clients app.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WarrantyClaimServiceSoap"
closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32"
maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384"
/>
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="">
<extendedProtectionPolicy
policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://10.0.1.37:8080/axis2/services/WarrantyClaimService"
binding="basicHttpBinding"
bindingConfiguration="WarrantyClaimServiceSoap"
contract="testWS.WarrantyClaimService"
name="WarrantyClaimServiceSoap" />
</client>
</system.serviceModel>
</configuration>


How can I consume this webservice from my .NET 3.5 Winform client?

Steven Cheng

unread,
Feb 18, 2010, 3:14:09 AM2/18/10
to
Hi kfransson,

From your description, you're encountering some security related error when
calling JAVA webservice through WCF client.

According to the WSDL document you provides, it seems the WSDL only
contains standard schema and service interface definition, but doesn't
contain any security policy defintion. Therefore, I think when you use "Add
ServiceReference" to generate the WCF proxy, it will not generate secuirty
related setting automatically. Do you know what is the expected security
setting(like client authentication type ...) of the server-side JAVA
webserivce? Or if possible, you can try requesting a sample
request/response soap message pair from the service provider as reference.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.


--------------------
From: =?Utf-8?B?S2FpIEZyYW5zc29u?= <kfra...@nospam.nospam>
Subject: java webservice requires usernametoken over basichttpbinding
Date: Wed, 17 Feb 2010 07:24:01 -0800

Kai Fransson

unread,
Feb 18, 2010, 5:12:06 AM2/18/10
to
From what I understand there could be a problem with WCF client not
supporting UserName credentials to be attached, when no Transport security is
applied?

The following is a soap message containing the operation claimStatus, notice
the <SOAP-ENV:Header tag.

<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAPENC="
http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="UsernameToken-100">
<wsse:Username>sgwsuser1</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-
1.0#PasswordText">pwd</wsse:Password>
</wsse:UsernameToken>
<wsu:Timestamp
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="Timestamp-100"/></wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<tns:claimStatus xmlns:tns="http://www.scania.com/sgws">
<claimStatusRec>
<nationCode>aa</nationCode>
<custNo>aaaaa</custNo>
<claimNo>a</claimNo>
<failNo>a</failNo>
<reconNo>a</reconNo>
<prodType>a</prodType>
<chassiNo/>
</claimStatusRec>
</tns:claimStatus>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Help is greatly appreciated..

Steven Cheng

unread,
Feb 23, 2010, 3:44:53 AM2/23/10
to
Hi kfransson,

Username authentication is mainly used with Message layer security instead
of transport layer though you can also configure WCF service to use
username authentication+ transport layer security(https/ssl). However, for
your case, you need to send usernametoken as clear text format which is not
supported in message secuirty mode(and also not supported with
usernameOverTransport security setting), you will need to use some custom
binding(a custom binding type derived from custombinding) to achieve such
kind of security effect.

So far Yaron Naveh has built an existing one for send username
authentication token as clear text with plain HTTP transport. You can try
using it for your service client:

#Introducing WCF ClearUsernameBinding
http://webservices20.blogspot.com/2008/11/introducing-wcf-clearusernamebindi
ng.html

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

--------------------
From: =?Utf-8?B?S2FpIEZyYW5zc29u?= <kfra...@nospam.nospam>
References: <365095EF-109F-4F2D...@microsoft.com>
<32EZlJH...@TK2MSFTNGHUB02.phx.gbl>
Subject: RE: java webservice requires usernametoken over basichttpbinding
Date: Thu, 18 Feb 2010 02:12:06 -0800

Kai Fransson

unread,
Feb 25, 2010, 6:46:01 AM2/25/10
to
I was never able to get Yaron's ClearUsernameBinding to work in my solution.
However, It appears I was successful modifying the app.config of my .NET
client, according to a suggestion from
http://sadeveloper.net/forums/p/4234/15549.aspx. This involves manually
adding the wsse-tags, and it appears to have solved my problem..

<endpoint
address="http://212.247.78.51:8080/axis2/services/WarrantyClaimService"


binding="basicHttpBinding"
bindingConfiguration="WarrantyClaimServiceSoap"
contract="testWS.WarrantyClaimService"
name="WarrantyClaimServiceSoap">

<headers>
<!--http://sadeveloper.net/forums/p/4234/15549.aspx-->
<wsse:Security mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

<wsse:UsernameToken wsu:Id="UsernameToken-5700630"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

<wsse:Username>username</wsse:Username>

<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>

</wsse:UsernameToken>

</wsse:Security>


</headers>
</endpoint>

0 new messages