Issue adding service reference for wcf - 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."

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

Error when using Parameters in Worklight HTTP Adapter

Using Worklight 6.2.0.0.
I'm trying to consume one of our corporate web services via Worklight's HTTP Adapter. I have the WSDL for the web service, and I used the "Discover Backend Services" tool to generate the adapter JavaScript and XML.
The web service has 2 input parameters and 3 output parameters, all strings.
When I come to invoke the procedure on the client, I'm doing this:
var invocationData = {
adapter : 'messageHandlerAdapter',
procedure : 'messageHandlerService_messageHandler',
parameters : ['a','b']
};
var invocationOptions = {
onSuccess : messageHandlerSuccess,
onFailure : messageHandlerFailure
};
WL.Client.invokeProcedure(invocationData,invocationOptions);
You can see the dummy parameters in the invocationData array. Running this results in the following error:
java.lang.String cannot be cast to org.mozilla.javascript.Scriptable
If I remove the parameters, I don't get an error and the web service call appears to be successful, but I don't get any response (obviously).
A search on the forums led me to this:
http://stackoverflow.com/questions/23192346/class-cast-java-lang-string-cannot-be-cast-to-org-mozilla-javascript-scriptable
Which is along the same lines, and the response was that there might be an invalid JSON object somewhere. However, all I've done is used the auto-generated adapter code and called it.
I'm very new to Worklight, so any advice is gratefully received!
WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="messageHandler" targetNamespace="urn:messageHandler" xmlns:tns="urn:messageHandler" xmlns:S2="urn:messageHandler:messageHandler" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:S1="urn:soap-fault:details" xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation>EncodingType=DOC_LITERAL, WSA_Product=10.1A - N/A</wsdl:documentation>
<wsdl:types>
<schema elementFormDefault="unqualified" targetNamespace="urn:soap-fault:details" xmlns="http://www.w3.org/2001/XMLSchema"><element name="FaultDetail"><complexType><sequence><element name="errorMessage" type="xsd:string"/><element name="requestID" type="xsd:string"/></sequence></complexType></element></schema>
<schema elementFormDefault="qualified" targetNamespace="urn:messageHandler:messageHandler" xmlns="http://www.w3.org/2001/XMLSchema"><element name="messageHandler"><complexType><sequence><element name="ipMessageParams" nillable="true" type="xsd:string"/><element name="ipMessageData" nillable="true" type="xsd:string"/></sequence></complexType></element><element name="messageHandlerResponse"><complexType><sequence><element name="result" nillable="true" type="xsd:string"/><element name="opMessageResponse" nillable="true" type="xsd:string"/><element name="opMessageData" nillable="true" type="xsd:string"/></sequence></complexType></element></schema>
</wsdl:types>
<wsdl:message name="messageHandler_messageHandlerResponse">
<wsdl:part name="parameters" element="S2:messageHandlerResponse"/>
</wsdl:message>
<wsdl:message name="FaultDetailMessage">
<wsdl:part name="FaultDetail" element="S1:FaultDetail"/>
</wsdl:message>
<wsdl:message name="messageHandler_messageHandler">
<wsdl:part name="parameters" element="S2:messageHandler"/>
</wsdl:message>
<wsdl:portType name="messageHandlerObj">
<wsdl:operation name="messageHandler">
<wsdl:input message="tns:messageHandler_messageHandler"/>
<wsdl:output message="tns:messageHandler_messageHandlerResponse"/>
<wsdl:fault name="messageHandlerFault" message="tns:FaultDetailMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="messageHandlerObj" type="tns:messageHandlerObj">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="messageHandler">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="messageHandlerFault">
<soap:fault name="messageHandlerFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="messageHandlerService">
<wsdl:port name="messageHandlerObj" binding="tns:messageHandlerObj">
<documentation></documentation>
<soap:address location="redacted"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Here is a link to a pic of the Service description in Project Explorer.
Generally we pass XML to SOAP based web services. With the case to worklight we have to convert XML to JSON and pass it to adapter. Considering your input SOAP is like
<a>
<b>value1</b>
<c>value2</c>
</a>
Your JSON for above XML would be
params= {
a:{
b:value1,
c:value2
}
}
So u will have to pass above JSON as parameter
headers={
"SOAPAction": "YOUR ACTION NAME"
}
And so your adapter call will look like this,
var invocationData = {
adapter : 'messageHandlerAdapter',
procedure : 'messageHandlerService_messageHandler',
parameters : [params,headers]
};
var invocationOptions = {
onSuccess : messageHandlerSuccess,
onFailure : messageHandlerFailure
};
WL.Client.invokeProcedure(invocationData,invocationOptions);
You currently have a service under your 'services' folder in your project.
In Project Explorer view right-click on your service and it should show you a sample parameter to be passed to the messageHandlerService_messageHandler procedure:
You can copy this sample JSON and invoke the adapter procedure by pasting and setting the sample values to your desired values:
If you also need to pass custom HTTP headers you should add a comma after the parameter JSON and add another JSON string with the custom headers.

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?

Axis 2 Exception while generating java code of a WCF Webservice

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

mono wsdl tool fails to parse salesforce enterprise.wsdl

Anyone know why this wsdl is not liked by the mono wsdl tool? Microsoft parses it. XMethods online wsdl validator parses it. Mono just doesn't seem to like it and I do not know enough to understand why.
# the error
mmcaughan#mmcaughan-dsktop:~/Projects/sftest$ wsdl enterprise.wsdl
Web Services Description Language Utility
Mono Framework v2.0.50727.1433
There where some warnings while generating the code:
enterprise.wsdl
- This web reference does not conform to WS-I Basic Profile v1.1
R2718: A wsdl:binding in a DESCRIPTION MUST have the same set of
wsdl:operations as the wsdl:portType to which it refers.
* Binding 'SoapBinding', in Service Description
'urn:enterprise.soap.sforce.com'
Writing file 'SforceService.cs'
relevant WSDL parts (I think)
<!-- Soap PortType -->
<portType name="Soap">
<operation name="login">
<documentation>Login to the Salesforce.com SOAP Api</documentation>
<input message="tns:loginRequest"/>
<output message="tns:loginResponse"/>
<fault message="tns:LoginFault" name="LoginFault"/>
<fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
<fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
</operation>
<!-- Soap Binding -->
<binding name="SoapBinding" type="tns:Soap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="login">
<soap:operation soapAction=""/>
<input>
<soap:header use="literal" message="tns:Header" part="LoginScopeHeader"/>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="LoginFault">
<soap:fault name="LoginFault" use="literal"/>
</fault>
<fault name="UnexpectedErrorFault">
<soap:fault name="UnexpectedErrorFault" use="literal"/>
</fault>
<fault name="InvalidIdFault">
<soap:fault name="InvalidIdFault" use="literal"/>
</fault>
</operation>
Older and more wiser now...
generate the C# from the wsdl
wsdl enterprise.wsdl -n:Sforce -o:SforceService.cs
the XmlAnyElement cannot have an empty namspace, so pop open SforceService.cs and remove it
this...
[System.Xml.Serialization.XmlAnyElement(Namespace="")]
public System.Xml.XmlElement[] Any {
get {
return this.anyField;
}
set {
this.anyField = value;
}
}
becomes...
public System.Xml.XmlElement[] Any {
get {
return this.anyField;
}
set {
this.anyField = value;
}
}
wsdl generates xml serialization against private members which doesn't work and has to be fixed
Unhandled Exception: System.InvalidOperationException: Member LoginScopeHeaderValueField not found in class Sforce.SforceService.
this...
[System.Web.Services.Protocols.SoapHeaderAttribute("LoginScopeHeaderValueField")]
becomes...
[System.Web.Services.Protocols.SoapHeaderAttribute("LoginScopeHeaderValue")]
search and replace ValueField" for ValueField"
then you might get this, which is a failure because mono does not install any root certificates in the trust store so https fails
Unhandled Exception: System.Net.WebException: Error writing request: The authentication or decryption has failed.
at System.Net.WebConnectionStream.WriteHeaders () [0x00000]
at System.Net.WebConnectionStream.SetHeaders (System.Byte[] buffer) [0x00000]
at (wrapper remoting-invoke-with-check) System.Net.WebConnectionStream:SetHeaders (byte[])
at System.Net.HttpWebRequest.SendRequestHeaders (Boolean propagate_error) [0x00000]
it is fixed with mozroots which will get all the certs mozilla ships with...
mozroots --import --sync
then everything works as describe
Sforce.SforceService binding = new Sforce.SforceService();
Sforce.LoginResult loginResult = binding.login("someuser", "somepass");
etc...