Microsoft MSDN describes the most universal service contract for a request reply operation as
[ServiceContract]
public interface IUniversalRequestReply
{
[OperationContract(Action="*", ReplyAction="*")]
Message ProcessMessage(Message msg);
}
If I make a contract like the one below, using basicHttp binding, it will not be WS-I compliant (using SOAPUI compliance check).
[OperationContract]
Message SomeOperation(Message msg);
I would think the most universal contract also would be the most interoperable.
Can anyone explain why it is not WS-I compliant? And more importantly - will using the Message class make the service less consumable to Java clients?
Any experience using the Message class is appreciated.
EDIT After first answer:
This is the full WSDL showing the service contract and operation contract.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="UniversalRequestReply" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:52437/UniversalRequestReply.svc?xsd=xsd0" namespace="http://schemas.microsoft.com/Message"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IUniversalRequestReply_SomeOperation_InputMessage">
<wsdl:part xmlns:q1="http://schemas.microsoft.com/Message" name="msg" type="q1:MessageBody"/>
</wsdl:message>
<wsdl:message name="IUniversalRequestReply_SomeOperation_OutputMessage">
<wsdl:part xmlns:q2="http://schemas.microsoft.com/Message" name="SomeOperationResult" type="q2:MessageBody"/>
</wsdl:message>
<wsdl:portType name="IUniversalRequestReply">
<wsdl:operation name="SomeOperation">
<wsdl:input wsaw:Action="http://tempuri.org/IUniversalRequestReply/SomeOperation" message="tns:IUniversalRequestReply_SomeOperation_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IUniversalRequestReply/SomeOperationResponse" message="tns:IUniversalRequestReply_SomeOperation_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IUniversalRequestReply" type="tns:IUniversalRequestReply">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SomeOperation">
<soap:operation soapAction="http://tempuri.org/IUniversalRequestReply/SomeOperation" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="UniversalRequestReply">
<wsdl:port name="BasicHttpBinding_IUniversalRequestReply" binding="tns:BasicHttpBinding_IUniversalRequestReply">
<soap:address location="http://localhost:52437/UniversalRequestReply.svc/basic"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
What the WSI Compliance test fails is not a missing service contract, but the Message input itself:
Name of message that failed: {http://tempuri.org/}IUniversalRequestReply_SomeOperation_InputMessage
Message: name={http://tempuri.org/}IUniversalRequestReply_SomeOperation_InputMessage
Part: name=msg
typeName={http://schemas.microsoft.com/Message}MessageBody
So using this Message class is not WS-I compliant of some reason.
The reason is the service is not complaint is because it does not define any service contract. Universal means this service can consume the soap message generated by any client that calls it. It does not attempt to deserialize the soap message because it never defines a contract of its own. WS-I compliance requires that a service define a static contract that can be expressed in WSDL.
Related
I don't want to set the namespace for every single one of my data contracts so I decided to use the ContractNamespace attribute in the AssemblyInfo.cs file of the project where my DataContracts reside. Here is the entry
[assembly: ContractNamespace("http://www.mycompany.com/MyProject/", ClrNamespace = "Company.Project.Client.Entities")]
This does nothing. It seems I HAVE to specify the namespace on all the data contracts like so:
[DataContract(Namespace = "http://www.mycompany.com/MyProject/")]
..and yes, I have verified that my DataContracts are in fact in the specified ClrNamespace. Why doesn't this work? I'm using .net 4.5. Thanks.
Update: Here is the WSDL generated when I use explicit namespacing on the contract:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:i0="http://www.company.com/Project/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="AccountService" targetNamespace="http://tempuri.org/">
<wsdl:import namespace="http://www.company.com/Project/" location="http://my.server.local/Project/Account/AccountService.svc?wsdl=wsdl0"/>
<wsdl:types/>
<wsdl:binding name="BasicHttpBinding_IAccountService" type="i0:IAccountService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetByAccountNumber">
<soap:operation soapAction="http://www.company.com/Project/IAccountService/GetByAccountNumber" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AccountService">
<wsdl:port name="BasicHttpBinding_IAccountService" binding="tns:BasicHttpBinding_IAccountService">
<soap:address location="http://my.server.local/Project/Account/AccountService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
And here is the WSDL I see when trying to use the ContractNamespace attribute in the AssemblyInfo.cs
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="AccountService" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://my.server.local/Project/Account/AccountService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://my.server.local/Project/Account/AccountService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="http://my.server.local/Project/Account/AccountService.svc?xsd=xsd2" namespace="http://www.company.com/Project/"/>
<xsd:import schemaLocation="http://my.server.local/Project/Account/AccountService.svc?xsd=xsd3" namespace="http://schemas.datacontract.org/2004/07/Company.Project.Core"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IAccountService_GetByAccountNumber_InputMessage">
<wsdl:part name="parameters" element="tns:GetByAccountNumber"/>
</wsdl:message>
<wsdl:message name="IAccountService_GetByAccountNumber_OutputMessage">
<wsdl:part name="parameters" element="tns:GetByAccountNumberResponse"/>
</wsdl:message>
<wsdl:portType name="IAccountService">
<wsdl:operation name="GetByAccountNumber">
<wsdl:input wsaw:Action="http://tempuri.org/IAccountService/GetByAccountNumber" message="tns:IAccountService_GetByAccountNumber_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IAccountService/GetByAccountNumberResponse" message="tns:IAccountService_GetByAccountNumber_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IAccountService" type="tns:IAccountService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetByAccountNumber">
<soap:operation soapAction="http://tempuri.org/IAccountService/GetByAccountNumber" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AccountService">
<wsdl:port name="BasicHttpBinding_IAccountService" binding="tns:BasicHttpBinding_IAccountService">
<soap:address location="http://my.server.local/Project/Account/AccountService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Ok, I had two issues here. First was a typo in one of the ClrNamespace that I can't believe took me so long to notice. The second was that my Contracts were in a project, lets say Company.Project.Contracts. That project had a few folders, lets say Data and Service (for data and service contracts), and had some contracts in the namespace Company.Project.Contracts. Thus, in my AssemblyInfo.cs file, I had to have MULTIPLE ContractNamespace attributes like so:
[assembly: ContractNamespace("http://www.company.com/Project/", ClrNamespace = "Company.Project.Business.Contracts")]
[assembly: ContractNamespace("http://www.company.com/Project/", ClrNamespace = "Company.Project.Business.Contracts.Service")]
[assembly: ContractNamespace("http://www.company.com/Project/", ClrNamespace = "Company.Project.Business.Contracts.Data")]
Also, #nodots, thanks for the pointers/help.
The ContractNamespace only applies to data contracts. You still have to set the service namespace on [ServiceContract].
The line
<xsd:import schemaLocation="http://my.server.local/Project/Account/AccountService.svc?xsd=xsd2" namespace="http://www.company.com/Project/"/>
in your WSDL indicates the ContractNamespace attribute does work.
I have a simple service definition:
[ServiceContract]
public interface IInterface12
{
[OperationContract]
void SendInterface12(string appId);
}
which I have implemented in the service as:
public void SendInterface12(string appId)
{
The thing is that the string parameter appId is not showing up. The complete WSDL is here:
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/" name="Interface12Service">
-<wsdl:types>
-<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import namespace="http://tempuri.org/" schemaLocation="http://localhost/TestInterface12/Interface12Service.svc?xsd=xsd0"/>
<xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" schemaLocation="http://localhost/TestInterface12/Interface12Service.svc?xsd=xsd1"/>
</xsd:schema>
</wsdl:types>
-<wsdl:message name="IInterface12_SendInterface12_InputMessage">
<wsdl:part name="parameters" element="tns:SendInterface12"/>
</wsdl:message>
-<wsdl:message name="IInterface12_SendInterface12_OutputMessage">
<wsdl:part name="parameters" element="tns:SendInterface12Response"/>
</wsdl:message>
-<wsdl:portType name="IInterface12">
-<wsdl:operation name="SendInterface12">
<wsdl:input message="tns:IInterface12_SendInterface12_InputMessage" wsaw:Action="http://tempuri.org/IInterface12/SendInterface12"/>
<wsdl:output message="tns:IInterface12_SendInterface12_OutputMessage" wsaw:Action="http://tempuri.org/IInterface12/SendInterface12Response"/>
</wsdl:operation>
</wsdl:portType>
-<wsdl:binding name="BasicHttpBinding_IInterface12" type="tns:IInterface12">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
-<wsdl:operation name="SendInterface12">
<soap:operation style="document" soapAction="http://tempuri.org/IInterface12/SendInterface12"/>
-<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
-<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
-<wsdl:service name="Interface12Service">
-<wsdl:port name="BasicHttpBinding_IInterface12" binding="tns:BasicHttpBinding_IInterface12">
<soap:address location="http://localhost/TestInterface12/Interface12Service.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
What am I missing? I have to have a service operation that takes a parameter but when I generate the proxy, there is no parameter for the string appId parameter. It says it takes 0 parameters.
Most probably the WSDL references an XSD file where your parameter is defined. Search for "import" or "include" to see the location of that XSD. If this is your wsdl location: http://myserver.com/X.svc?WSDL=WSDL0 then the XSD is in http://myserver.com/x.svc?XSD=XSD0 (or XSD1, XSD2...). Possibly your WSDL references another WSDL (WSDL1) which is the one that references the XSD (or a few of them).
I am trying to connect to an external webservice and have no control over it.
The wsdl has a few unresolved urls. Neither Soap UI not svcutil were able to make any use out of it.
So I browsed to this wsdl and did a 'Save As' to a xml document. Then I went and manually changed it these few to the correct one.
For eg:
https://b2borexatest.oracleoutsourcing.com/soa-infra/services/default/MMISSOAPRequestReceiver!1.0*soa_d48cf4e0-5e7b-43ad-b430-727180d48841/RouteEDITransactions_ep?WSDL. T
This was the original webservice Wsdl given. and then they changed it to
https://orserviceb2btest.oracleoutsourcing.com/soa-infra/services/default/MMISSOAPRequestReceiver!1.0/CORERule220.wsdl
I am able to browse to the second url but it still contains some traces of the old one 'b2b....'
So I went and manually changed these traces to reflect to the correct one.
By doing so, I was able to create a proxy using svcutil.
Question: Could this be the possible reason for getting a webservice proxy returns null
SOAP UI request
<soapenv:Envelope xmlns:cor="http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<cor:COREEnvelopeRealTimeRequest>
<PayloadType>123</PayloadType>
<ProcessingMode>XXX</ProcessingMode>
<PayloadID>72</PayloadID>
<TimeStamp>2013-07-13:T23:30:29:45</TimeStamp>
<SenderID>MID</SenderID>
<ReceiverID>OID</ReceiverID>
<CORERuleVersion>2.2.0</CORERuleVersion>
<Payload>MY Input string</Payload>
</cor:COREEnvelopeRealTimeRequest>
</soapenv:Body>
This is the working SOAP UI response
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Body>
<COREEnvelopeRealTimeResponse xmlns:cor="http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd" xmlns="http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd">
<cor:PayloadType>XXX</cor:PayloadType>
<cor:ProcessingMode>23</cor:ProcessingMode>
<cor:PayloadID>372</cor:PayloadID>
<cor:TimeStamp>2013-08-04T23:38:32.083-05:00</cor:TimeStamp>
<cor:SenderID>OID</cor:SenderID>
<cor:ReceiverID>RID</cor:ReceiverID>
<cor:CORERuleVersion>2.2.0</cor:CORERuleVersion>
<cor:Payload>Response String</cor:Payload>
<cor:ErrorCode>Success</cor:ErrorCode>
<cor:ErrorMessage></cor:ErrorMessage>
</COREEnvelopeRealTimeResponse>
</env:Body>
I don't see any conflictions in the request/response
These are some relevant pieces of the wsdl
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:CORE="http://www.caqh.org/SOAP/WSDL/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:CORE-XSD="http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd" xmlns="http://schemas.xmlsoap.org/wsdl/" name="CORE" targetNamespace="http://www.caqh.org/SOAP/WSDL/">
<wsdl:types>
<xsd:schema xmlns="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified" targetNamespace="http://www.caqh.org/SOAP/WSDL/">
<xsd:import namespace="http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd" schemaLocation="xsd/CORERule2.2.0.xsd"></xsd:import>
</xsd:schema>
</wsdl:types>
<wsdl:message name="RealTimeRequestMessage">
<wsdl:part name="body" element="CORE-XSD:COREEnvelopeRealTimeRequest"></wsdl:part>
</wsdl:message>
<wsdl:message name="RealTimeResponseMessage">
<wsdl:part name="body" element="CORE-XSD:COREEnvelopeRealTimeResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="CORETransactions">
<wsdl:operation name="RealTimeTransaction">
<wsdl:input message="CORE:RealTimeRequestMessage"></wsdl:input>
<wsdl:output message="CORE:RealTimeResponseMessage"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CoreSoapBinding" type="CORE:CORETransactions">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap12:binding>
<wsdl:operation name="RealTimeTransaction">
<soap12:operation soapAction="RealTimeTransaction" style="document"></soap12:operation>
<wsdl:input>
<soap12:body use="literal"></soap12:body>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"></soap12:body>
</wsdl:output>
</wsdl:operation>
I don't see where the proxy class could loose it although Fiddler captures the correct response.
This is a piece of where I invoke the service method using proxy client class
var ORrealTimeTrans = new COREEnvelopeRealTimeRequest()
{
PayloadType = "blabla",
ProcessingMode = bla,
PayloadID = bla,
CORERuleVersion = bla,
SenderID = sid,
ReceiverID = rid,
TimeStamp = DateTime.UtcNow.ToString("yyyy-MM-ddThh:mm:22Z"),
Payload = input
};
_ORclient.ClientCredentials.UserName.UserName = UserID;
_ORclient.ClientCredentials.UserName.Password = Password;
var resp = _ORclient.RealTimeTransaction(ORrealTimeTrans);
THis one _ORclient.RealTimeTransaction(ORrealTimeTrans) comes out null.
Could it be possible that I've changed some occurences of b2b to orservice and this proxy returns null?
Please suggest
I'm hosting a WCF Web Service with the following WSDL (a simple service using wsHttpBinding and SSL for transport security):
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="MagicEightBallService" targetNamespace="http://tempuri.org/">
<wsp:Policy wsu:Id="WSHttpBinding_TransportSecurity_IMagicEightBallService_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
<wsaw:UsingAddressing/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://my.local.domain.name/MagicEightBall/MagicEightBallService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IMagicEightBallService_GetAdvice_InputMessage">
<wsdl:part name="parameters" element="tns:GetAdvice"/>
</wsdl:message>
<wsdl:message name="IMagicEightBallService_GetAdvice_OutputMessage">
<wsdl:part name="parameters" element="tns:GetAdviceResponse"/>
</wsdl:message>
<wsdl:portType name="IMagicEightBallService">
<wsdl:operation name="GetAdvice">
<wsdl:input wsaw:Action="http://tempuri.org/IMagicEightBallService/GetAdvice" message="tns:IMagicEightBallService_GetAdvice_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IMagicEightBallService/GetAdviceResponse" message="tns:IMagicEightBallService_GetAdvice_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WSHttpBinding_TransportSecurity_IMagicEightBallService" type="tns:IMagicEightBallService">
<wsp:PolicyReference URI="#WSHttpBinding_TransportSecurity_IMagicEightBallService_policy"/>
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetAdvice">
<soap12:operation soapAction="http://tempuri.org/IMagicEightBallService/GetAdvice" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MagicEightBallService">
<wsdl:port name="WSHttpBinding_TransportSecurity_IMagicEightBallService" binding="tns:WSHttpBinding_TransportSecurity_IMagicEightBallService">
<soap12:address location="https://localhost/MagicEightBall/MagicEightBallService.svc"/>
<wsa10:EndpointReference>
<wsa10:Address>
https://localhost/MagicEightBall/MagicEightBallService.svc
</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Why do I get errors when I try to consume this from Java? When I try to consume it using Axis2/Java, I get the error:
org.apache.axis2.AxisFault: Must Understand check failed for header http://www.w3.org/2005/08/addressing : Action
And when I try to use JAX-WS, I get the error:
javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers:[{http://www.w3.org/2005/08/addressing}Action] are not understood
So far I haven't had any success with either of these, and I'm not sure whether a fix needs to be applied to the server or the client.
(See a related question I posted for more details, including the WCF Web.config).
Running:
ServiceClient sc = stub._getServiceClient();
sc.engageModule("addressing");
engages the Addressing module, fixing this issue.
I know the post is old, but someone may still face this problem.
I'm using JAX-WS, and I was having the same issue. After reading https://jax-ws.java.net/jax-ws-21-ea3/docs/wsaddressing.html#On_the_client_side I've found a solution that worked for me.
The code was breaking in the following line:
IFooService service = new FooService().getWSHttpBindingIFooService();
What I've done is the following:
IFooService service = new FooService().getWSHttpBindingIFooService(new javax.xml.ws.soap.AddressingFeature());
That's it.
also add addressing.mar and soapmonitor.mar to your library path.
I too had the same problem.
In my case the webservice's WSDL was created using WCF in .net and we are consuming it at JAVA side. After several tries I noticed that the corresponding header was missing in the web service. I asked my dotnet team to add a - port name in the webservice.This port name just a normal name in the web service. This was needed because at JAVA side we need port type and port name to actually access the webservice.
Try to add below lines at the .net side inside the service and then try to consume at JAVA side.
[ServiceContract(Namespace = "BookStockWebService", Name = "BookStock")]
[ServiceBehavior(Namespace = "BookStockWebServiceport", Name = "BookStockPort")]
If client has been generated using Apache CXF and facing this issue, then below helps:
Add below annotation to IService interface:
#Addressing(enabled=true, required=false)
In client class that is where the service is being obtained for calling:
ServiceImpl service = new ServiceImpl(wsdl,service); IService port = service.getWSHttpBindingIService(new AddressingFeature(true));
Import for AddressingFeature is javax.xml.ws.soap.AddressingFeature;
I'm generating client side web service code using svcutil. The wsdl contract I'm using contains a soap fault. When the code is generated the fault seems to be wrapped in the namespace it was defined in the contract.
Can anyone explain why?
I'm simply running svcutil [filename]
Example WSDL:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="HelloFault">
<s:complexType/>
</s:element>
<s:element name="HelloWorld">
<s:complexType/>
</s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="parameters" element="tns:HelloWorld"/>
</wsdl:message>
<wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="parameters" element="tns:HelloWorldResponse"/>
</wsdl:message>
<wsdl:message name="NewMessage">
<wsdl:part name="detail" element="tns:HelloFault"/>
</wsdl:message>
<wsdl:portType name="Service1Soap">
<wsdl:operation name="HelloWorld">
<wsdl:input message="tns:HelloWorldSoapIn"/>
<wsdl:output message="tns:HelloWorldSoapOut"/>
<wsdl:fault name="FaultName" message="tns:NewMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Service1Soap12" type="tns:Service1Soap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="HelloWorld">
<soap12:operation soapAction="http://tempuri.org/HelloWorld" soapActionRequired="" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="FaultName">
<soap12:fault name="FaultName" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
Generates:
namespace tempuri.org
{
using System.Runtime.Serialization;
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="HelloFault", Namespace="http://tempuri.org/")]
public partial class HelloFault : object, System.Runtime.Serialization.IExtensibleDataObject
{
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
public System.Runtime.Serialization.ExtensionDataObject ExtensionData
{
get
{
return this.extensionDataField;
}
set
{
this.extensionDataField = value;
}
}
}
}
But other types declared in the contract are declared without a namespace?
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class HelloWorldRequest
{
...
You have to use the /UseSerializerForFaults attribute on svcutil, this will cause the XmlSerializer to be used for reading and writing faults (but only those), instead of the default DataContractSerializer (which will still be used for the rest of the stuff).
This seems to be a genuine bug - more info on my blog post.
I'm not sure I understand what the problem is... can you clarify?
From the looks of it, it would seem WCF is doing the right thing... the generated class has the right namespace URI in the [DataContract] attribute according to the schema in the WSDL fragment you showed.
What were you expecting?
Update: OK, I see what you're saying, but in this specific case, it's not unexpected either. If you look closely, notice that the other class you mention (HelloWorldRequest) is a Message Contract, not a DataContract. Message Contracts don't have namespaces themselves, though they can specify a namespace for the wrapper element around the message body (see the WrapperNamespace property).
In your case, the message contract specifies that it is not wrapped, so the WrapperNamespace wouldn't apply anyway.
Update #2: Regarding the CLR namespace (and not the XML namespace URI), SvcUtil does give you a way to control that; check out the /namespace: argument in the documentation.