Axis 2 Exception while generating java code of a WCF Webservice - wcf

I've a web service created using WCF. It uses CustomException as well.
When i use Axis 2 to generate java code from it (WSDL2JAVA) it thorws the following error:
> IWAB0399 Error in generating java from WSDL
> Missing <soap:fault> element inFault Operation "CustomExceptionFault" in operation "CustomExceptionFault", in binding
> GetPDFs
> java.io.IOException: ERROR: Missing <soap:fault> element inFault "CustomExceptionFault" in operation "CustomExceptionFault", in binding
> GetPDFs at
> org.apache.axis.wsdl.symbolTable.SymbolTable.faultFromSOAPFault(Unknown
> Source)
My WSDL snippet
<wsdl:binding name="tdsServiceSoap12" type="tns:ITDSService">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetPDFs">
<soap12:operation soapAction="http://tempuri.org/ITDSService/GetPDFs" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="CustomExceptionFault">
<soap12:fault name="CustomExceptionFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
Hope it clarifies. If need further information please let me know.
Regards

This article helped me solve my problem with some other tweaks.
http://weblogs.asp.net/pglavich/archive/2010/03/16/making-wcf-output-a-single-wsdl-file-for-interop-purposes.aspx

Related

WCF SOAP service, single wsdl, empty namespace in soap:fault, not WS-I compliant, BP2019

When coding a SOAP service in C#, running it and then retrieving the WSDL from the service with ?singlewsdl option, the generated WSDL has an empty namespace attribute in the element, spoiling WSI compliance (checked with SoapUI) and resulting in error code BP2019, indicating an illegal namespace in the soap fault.
The service method is in a base interface, from which the services derive their own interfaces.
Definition is in a service interface:
[OperationContract(
Action = "http://mynamespace.com/services/2014/06/23/MyBaseContract/GetInterfaceVersionRequest",
ReplyAction = "http://mynamespace.com/services/2014/06/23/MyBaseContract/GetInterfaceVersionResponse" )]
[FaultContract(typeof(string), Name="NonsenseFault")]
string GetInterfaceVersion();
The WSDL generated by the service with ?singlewsdl contains an empty namespace attribute:
<wsdl:operation name="GetInterfaceVersion">
<soap:operation soapAction="http://mynamespace.com/services/2014/06/23/MyBaseContract/GetInterfaceVersionRequest" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="NonsenseFault">
<soap:fault use="literal" name="NonsenseFault" namespace=""/> <!-- spoils WS-I compliance! -->
</wsdl:fault>
</wsdl:operation>
According to WS-I rules, the soap:fault element must not have a namespace attribute at all.
Can I do anything about this?
You may be able to solve the issue by setting the FaultContract attribute Namespace property.
[FaultContract(typeof(string), Name="NonsenseFault", Namespace="http://my.nonsense.fault")]
http://msdn.microsoft.com/en-us/library/system.servicemodel.faultcontractattribute(v=vs.110).aspx

Getting wrong data while reading wsdl dynamically

This is my WCF WSDL file.
<wsdl:portType name="IMyService">
<wsdl:operation name="add">
<wsdl:input wsaw:Action="http://pcname:9000/WcfService/MyService/IMyService/add"
message="tns:IMyService_add_InputMessage"/>
<wsdl:output wsaw:Action="http://pcname:9000/WcfService/MyService/IMyService/addResponse"
message="tns:IMyService_add_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="sub">
<wsdl:input wsaw:Action="http://pcname:9000/WcfService/MyService/IMyService/sub"
message="tns:IMyService_sub_InputMessage"/>
<wsdl:output wsaw:Action="http://pcname:9000/WcfService/MyService/IMyService/subResponse"
message="tns:IMyService_sub_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
I am trying to dynamically add reference to my project.
While reading WSDL dynamically I am getting an exception
Line in code:
ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);
Error:
Exception: Unable to import binding 'BasicHttpBinding_IMyService' from namespace http:// pcname:9000/WcfService/MyService/.
Inner excepetion : {"The element 'http:// pcname:9000/WcfService/MyService/:add' is missing."}
Why am I getting ":" (colon) before "add" function?

WCF Universal service contract and WS-Interoperability compliance

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.

How to get wsdl input and output names to appear

I have a WCF web service project (VB.NET 3.5), and the WSDL it generates does not have the input and output names, like this:
<wsdl:operation name="getListing">
<soap:operation soapAction="getListing" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
I need the input and output names to be defined in the WSDL, like this:
<wsdl:operation name="getListing">
<wsdlsoap:operation soapAction="getListing"/>
<wsdl:input name="getListingRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getListingResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
This is the definition for the method in question:
<OperationContract(Action:="getListing")> _
<WebMethod(Description:="Retrieve Base64 binary.", EnableSession:=True)> _
Public Overloads Overrides Function getListing(<System.Xml.Serialization.XmlElementAttribute([Namespace]:="http://namespacehere.com")> ByVal getListingRequest As ListingRequest) As ListingResponse
I feel like I'm missing something stupid, does anyone know what it is? There are so many options and parameters, I can't find the right ones that determine this.

Issue adding service reference for wcf

Warning 1 Custom tool warning: Cannot import wsdl:binding
Detail: The given key was not present in the dictionary.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://wrapper.dao.ccarwebservice.ids.com']/wsdl:binding[#name='CCaRWebServiceHttpBinding'] C:\Users\me\Documents\Visual Studio 2008 \Projects\CcarsWcfTest\CcarsWcfTest\Service References\ServiceReference1\Reference.svcmap 1 1 CcarsWcfTest
what can I do to resolve this issue?
I've tried running the service utility from the command prompt and adding a service reference to my project. I've also gone into the advanced setting in the Add Service Reference dialog and deselected 'Reuse types in all referenced assemblies'.
EDIT
Here is the part of the wsdl I think it's referring to..
<wsdl:binding name="CCaRWebServiceHttpBinding" type="ns:CCaRWebServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="fnGetccarprogramsummaryarray">
<http:operation location="CCaRWebService/fnGetccarprogramsummaryarray"/>
<wsdl:input>
<mime:content type="text/xml" part="fnGetccarprogramsummaryarray"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="fnGetccarprogramsummaryarray"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="fnGetccarprogramsummary">
<http:operation location="CCaRWebService/fnGetccarprogramsummary"/>
<wsdl:input>
<mime:content type="text/xml" part="fnGetccarprogramsummary"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="fnGetccarprogramsummary"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
public partial class fnGetccarprogramsummaryarrayRequest
{
public fnGetccarprogramsummaryarrayRequest()
{
}
}
the others are like this...
public partial class fnGetccarprogramsummaryRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://wrapper.com", Order=0)]
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public string programAcronym;
public fnGetccarprogramsummaryRequest()
{
}
public fnGetccarprogramsummaryRequest(string programAcronym)
{
this.programAcronym = programAcronym;
}
}
Where did the WSDL come from? How was it generated?
It could be the the definition of the input and return types are missing.
fnGetccarprogramsummaryarray
fnGetccarprogramsummary.
It could be that it is trying to look for the definition in an array of types and not finding it.
EDIT
I think that I found it you have a POST binding and the tool only supports a SOAP binding
http://social.msdn.microsoft.com/Forums/en/wcf/thread/859a2c87-02db-469d-ab65-c558ff091e61
The key that is not present is then the SOAP binding.
After searching.. the only solution I've come across is to ignore this error.
"It is internal implementation detail of svcutil.
The error is probably since the wsdl contains a POST binding and the utlity only works on SOAP bindings. But if there is another SOAP binding in the wsdl it works."