I have a problem with web service connection. It says,
Possible SOAP version mismatch:
Envelope namespace
http://schemas.xmlsoap.org/wsdl/ was
unexpected. Expecting
http://schemas.xmlsoap.org/soap/envelope/.
when i call webservice's method. Do you have any idea about my problem?
It looks like you're providing the wrong namespace when creating the SOAP envelope - it should look similar to this:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
It's the third one that is probably wrong in your case.
I ran into the same issue dealing with a legacy web service hosted on a mainframe(obviously not .net). The url for the service was specified in the config of the client, but the wsdl file had not been included in the deployment. I suspect that on the initial call, the .Net client attempted to retrieve a fresh wsdl. The service wasn't expecting that and we received the "Possible SOAP version mismatch" error.
We encountered this error, because we set the c#-WebServiceProxy-URL to a wrong value.
we did
WebService ws = new WebService();
ws.Url = "http://URL_TO_WEBSERVICE?WSDL";
var response = ws.CallFunction()
Here the ?WSDL at the end of the URL caused the error.
Related
I'm trying to create an application in Visual Studio 2015 that calls a web service set up on one of our servers (It's a third party web service so I don't really know anything about its implementation).
I can browse to the web service definition, and view the wsdl and singleWsdl definitions.
In Visual Studio, I right-click on the Service References folder and choose 'Add Service Reference...', type in the URL to the web service (I've also tried the wsdl and singleWsdl URLs which produce the same result) and click 'Go'. The operations are shown, so I enter a namespace and click 'OK'.
At this point lots of code is generated, but, and I think this is the cause of my problem, there are no changes made to the config file.
When I try and run my code I get an error:
"An exception of type 'System.InvalidOperationException' occurred in
System.ServiceModel.dll but was not handled in user code
Additional information: Could not find default endpoint element that
references contract 'CRMContactEventService.ContactEventService' in
the ServiceModel client configuration section. This might be because
no configuration file was found for your application, or because no
endpoint element matching this contract could be found in the client
element."
I've tried using SvcUtil.exe to generate the proxy but it also does not generate any config file. I've tried using wsdl.exe to generate another wsdl file but that just generates an empty file. I've tried saving the singleWsdl file to my local drive and using that instead of the URL but the results are the same.
Now after lots of searching, I have tried to manually add what I think is missing to the web.config file:
<system.serviceModel>
<client>
<endpoint address="http://...<url to service>.../ContactEventService.svc"
binding ="netHttpBinding"
contract = "CRMContactEventService.ContactEventService" />
</client>
</system.serviceModel>
This changes the error message:
"An exception of type 'System.ServiceModel.EndpointNotFoundException'
occurred in mscorlib.dll but was not handled in user code
Additional information: There was no endpoint listening at
http://....../ContactEventService.svc that could
accept the message. This is often caused by an incorrect address or
SOAP action. See InnerException, if present, for more details."
InnerException contains:
"The remote server returned an error: (404) Not Found."
I have tried several different values for the binding parameter in the web.config file as I don't know which one to use, but most return the above error or some other error which makes it clear that I made a bad choice.
I've been looking at this problem for far too long and I cannot see how to get this working, or even whether it's a problem with what I am doing or a problem with the web service.
Can you first manually make the SOAP call to the actual service endpoint and check if you're getting the expected result? The free SoapUI client is very useful for this type of troubleshooting. (Having said that, if the remote endpoint is responding correctly, I think you're on the right path to figuring this out.)
I took the wsdl file given by a tibco web service and I put it in my project, after that I created the web reference giving to vs 2005 (yes I'm working on a legacy project) that wsdl file. VS 2005 generated the proxy and I used it in my vb.net code.
When I call the method exposed by the proxy I always get a null result. If I call the service with soapUI it give a correct response with expected data. How this is possible? The wsdl is given by the tibco service itself how can vs 2005 misunderstand the result of the call?
Many thanks in advance for any answer.
My vb code is:
Dim EvalError As Company.FrontEnd.Agents.Ws_EvaluateAgency.tnsERRORAlpha
Dim EvaluateOutput() As Company.FrontEnd.Agents.Ws_EvaluateAgency.tnsPNREvaluate
EvaluateInput.EvaluationOption.EvaluatorOption.ElaborationMode = FrontEnd.Agents.Ws_EvaluateAgency.tnsTypeOfElaboration.AutopilotAgy '' Fase III
EvalError = ws_Valutazione.AgencyEvaluate(EvaluateInput, EvaluateOutput)
The input object have correct data. The output object is defined an so the EvalError
SOLVED: Was missing namespace specification in wsdl:input and wsdl:output tag of the wsdl
SOLVED: Was missing namespace specification in wsdl:input and wsdl:output tag of the wsdl
For an unknown (for me) reason you MUST set namespace="http://InputMessageNamespace" in wsdl:input and namespace="http://OutputMessageNamespace" in wsdl:output
I have a problem when calling web Services in ASP.net MVC , I do the following
add the web service by add service reference to solution, and I include the service.cs file to the solution also, but when I try to create object in home controller , I have the following error
Could not find default endpoint element that references contract 'Service' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
can any one help me please
thanks
There's a couple things going on here. First, you're using SVCUTIL to generate a proxy and configuration settings for a non-WCF service - .asmx is legacy. I was able to generate a proxy and config settings, but to overcome the error you got you need to call one of the overloaded versions of WeatherHttpClient.
I'm not 100% sure, but this is what I think based on what I observed.
The reason is because there are two endpoints defined in the configuration file (one for SOAP 1.1 and one for SOAP 1.2), and since both endpoints are named there is no default endpoint to choose from.
When I used var x = new WeatherHttpClient(new BasicHttpBinding("WeatherSoap"), new EndpointAddress("http://wsf.cdyne.com/WeatherWS/Weather.asmx")); I was able to create the proxy just fine.
However, when I called GetCityForecastByZip I got the following error:
Server did not recognize the value of HTTP Header SOAPAction: http://ws.cdyne.com/WeatherWS/WeatherHttpGet/GetCityForecastByZIPRequest.
So then I used WSDL.exe to generate the proxy a la .ASMX style. I included that in my project, and the following code returned a result (after including a reference to System.Web.Services - I was using a console app):
var x = new Weather();
ForecastReturn result = x.GetCityForecastByZip("91504");`
I would suggest for simplicity using WSDL.exe to generate the proxy for your service, as it seems to be simpler.
I will also add that I've done very little MVC, but I don't think this is an MVC issue. I hope this helps you.
I am trying to create a method in a class that accesses a WebMethod on a Web Service using WebClient, and am running into problems. Using VS2010 on Windows.
First of all, yes I know I could create a Web Reference to the web service in the class library, of course this is design time binding. However, I need to be able to get to the web service using information only available at run time. There's a business reason for this that I won't go into here, just go with it, please.
This appears to be possible using the WebClient class from the System.Net namespace. And in fact I am able to get to the service in question, but the data I am sending to it doesn't appear to be in a correct format, although for all I can tell it is a properly formatted SOAP message.
The WebException contains the following message: "The remote server returned an error: (415) Unsupported Media Type."
Here's the code:
public string DoingBusiness()
{
WebClient client = new WebClient();
string destUri = "http://localhost/Service/Service.asmx?op=CommunicationsCheck";
StreamReader reader = new StreamReader(#"CommCheck.xml");
string data = String.Format(reader.ReadToEnd(), "The End is Near!");
reader.Close();
string response = client.UploadString(destUri, data);
return response;
}
Leaving off the actual xmlns, which is sensitive, the data read by the StreamReader above looks like:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CommunicationsCheck xmlns="http://.../">
<communication>{0}</communication>
</CommunicationsCheck>
</soap:Body>
</soap:Envelope>
This looks like a perfectly fine SOAP message. Of course the "{0}" gets filled in with the payload string. If the WebMethod "CommunicationsCheck(string communication) ran successfully it would return:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://[service url]/">You sent 'The End is Near!'</string>
Which it does if I access the service through a browser, or through a design-time web reference.
So, the question is, what am I doing wrong here that I get the "(415) Unsupported Media Type"
Are there properties on the WebClient that need to be set? Do I perhaps need to provide a Header containing a UserAgent? Or something else?
Darn. I guess I should let someone else answer the question, but answering one's own question is acceptable, if one finds it oneself.
Anyway, some further research on the problem seemed to suggest that one surmise on my part, namely that there might be some Header property I needed to set, was a possible solution. And the research suggested that the property would be "content-type" needed to be set as "text/xml". So I added this line:
client.Headers.Add("content-type", "text/xml");
just before the UploadString method call.
BINGO!
The expected response occurred.
Has anyone ever noticed that answers to perplexing questions sometimes become self-evident once the question is posed, but not before? Interesting phenomenon.
So, I'm trying to use soap to communicate with a webservice and getting errors. What is frustrating about this particular issue is that it works perfectly fine with my local copy of the webservice (yes, I tried turning off my firewall) and used to work fine with a previous version of the webservice and client. I suspect I could (though I'll have to look up how to do this) add an action parameter to what the client is sending. However, I am very curious why it was able to work previously without one.
Edit Clarification: I think the relevant code was the same between when it stopped working and when it worked (since I checked against an old version of the program and had the same problems and the relevant code was the same...unless I missed something subtle). I know the actual server program is the same on both the local copy and the remote copy, even though it only works locally. I thus suspect there is some sort of weird configuration setting I can change to make it work.
Error message: "soap:ClientUnable to handle request without a valid action parameter. Please supply a valid soap action."
VB Client Code
'WEB_SERVICE_URL_CONST = http://site.com/foo.asmx
'domDoc.xml = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><TestConnection xmlns="http://site.com"/></soap:Body></soap:Envelope>
Dim oXml As New XMLHTTPRequest
oXml.Open "POST", WEB_SERVICE_URL_CONST, False, "\"
oXml.setRequestHeader "Content-Type", "text/xml"
oXml.send domDoc.xml
C# Server Code
[WebMethod]
public int TestConnection()
{
return 1;
}
Are you sure the first two lines are not commented-out in the real version? The sample code seems to have no value for WEB_SERVICE_URL_CONST and domDoc.xml, and an empty Soap request would indeed not specify any action?
EDIT: I find the "used to work fine with a previous version of the webservice and client" a bit confusing. If you actually changed both the client and the server, then what part did not change?
The problem was with the xmlns="http://site.com" code. When I tested locally, I was using xmlns="http://localhost" by mistake. In fact, this should not be changed on the client or the server (in the server, this would be WebService(Namespace =...)), regardless of where I am testing...but if it does change, the client and server need to match.