Following is the WSDL file and I am unable to generate the Proxy class for this WSDL file.
<?xml version ='1.0' encoding ='ISO-8859-1' ?>
<definitions name='SunesisService' targetNamespace='https://exg.sunesis.uk.net/' xmlns:tns='https://exg.sunesis.uk.net/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<wsdl:types>
<xsd:schema targetNamespace="https://exg.sunesis.uk.net/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="destinyXML">
<xsd:complexType name="mimeXmlType" use="required">
<xsd:sequence>
<xsd:any/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<message name='receiveILRRequest'>
<part name='receiveILRRequest_username' type='xsd:string' />
<part name='receiveILRRequest_password' type='xsd:string' />
<part name='receiveILRRequest_destinyXMLFileName' type='xsd:string' />
<part name='receiveILRRequest_destinyXML' type='mimeXmlType' />
</message>
<message name='receiveILRResponse'>
<part name='receiveILRResponse_Result' type='xsd:string' />
</message>
<portType name='DestinyReceipt'>
<operation name='acceptEXG'>
<input message='tns:receiveILRRequest'/>
<output message='tns:receiveILRResponse'/>
</operation>
</portType>
<binding name='SunesisBinding' type='tns:DestinyReceipt'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' />
<operation name='acceptEXG'>
<soap:operation soapAction='urn:localhost-catalog#acceptILR'/>
<input>
<soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
</input>
<output>
<soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
</output>
</operation>
</binding>
<service name='SunesisService'>
<port name='SunesisPort' binding='SunesisBinding'>
<soap:address location='https://exg.sunesis.uk.net/module_soap/sunesis.php' />
</port>
</service>
You must close your definitions node in the end of your document
try with this format
<definitions name='SunesisService' targetNamespace='https://exg.sunesis.uk.net/' xmlns:tns='https://exg.sunesis.uk.net/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
..........
<service name='SunesisService'>
<port name='SunesisPort' binding='SunesisBinding'>
<soap:address location='https://exg.sunesis.uk.net/module_soap/sunesis.php' />
</port>
</service>
</definitions>
Related
I'm using WCF client in this very simple way:
using (var client = new ExampleService_TestClient())
{
client.ClientCredentials.UserName.UserName = "user";
client.ClientCredentials.UserName.Password = "pass";
var request = new ExampleService_TestRequest(requestData);
var response = client.ExampleService_Test(request);
// response.Response_MT is null
// when it should have errorMsg="OK"
}
The data is sent correctly.
However the response property errorMsg is null.
Here is the envelope:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Inbound_MT xmlns="https://example.com/ExampeService/">
<event_id xmlns="">1</event_id>
<event_name xmlns="">insert</event_name>
<event_date xmlns="">2017-06-22 16:09</event_date>
<employee_number xmlns="">666</employee_number>
<employee_first_name xmlns="">Chuck</employee_first_name>
<employee_last_name xmlns="">Inserted Norris</employee_last_name>
</Inbound_MT>
</s:Body>
</s:Envelope>
The response I see using fiddler:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header></soap:Header><soap:Body><Response_MT>
<errorMsg>OK</errorMsg>
</Response_MT></soap:Body>
</soap:Envelope>
WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:p1="https://example.com/ExampeService/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" targetNamespace="https://example.com/ExampeService/">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="https://example.com/ExampeService/" targetNamespace="https://example.com/ExampeService/">
<xsd:element name="Inbound_MT" type="Inbound_DT" />
<xsd:element name="Response_MT" type="Response_DT" />
<xsd:complexType name="Inbound_DT">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="event_id" type="xsd:integer" />
<xsd:element maxOccurs="1" minOccurs="1" name="event_name" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="event_date" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="employee_number" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="0" name="employee_first_name" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="0" name="employee_last_name" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Response_DT">
<xsd:sequence>
<xsd:element name="errorMsg" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="Inbound_MT">
<wsdl:documentation />
<wsdl:part element="p1:Inbound_MT" name="Inbound_MT" />
</wsdl:message>
<wsdl:message name="Response_MT">
<wsdl:documentation />
<wsdl:part element="p1:Response_MT" name="Response_MT" />
</wsdl:message>
<wsdl:portType name="ExampleService_Test">
<wsdl:documentation />
<wsdl:operation name="ExampleService_Test">
<wsdl:documentation />
<wsdl:input message="p1:Inbound_MT" />
<wsdl:output message="p1:Response_MT" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ExampleService_TestBinding" type="p1:ExampleService_Test">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsp:Policy>
<wsp:PolicyReference URI="#BN__binding" />
</wsp:Policy>
<wsdl:operation name="ExampleService_Test">
<soap:operation soapAction="https://example.com/ExampeService//ExampleService_Test" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SOME_GREAT_SERVICE">
<wsdl:documentation>WS_GS</wsdl:documentation>
<wsdl:port binding="p1:ExampleService_TestBinding" name="ExampleService_Test">
<soap:address location="https://endpointaddress/cxf/ExampleService_Test" />
</wsdl:port>
</wsdl:service>
<wsp:UsingPolicy required="true" />
<wsp:Policy wsu:Id="BN__binding">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken>
<wsp:Policy>
<wsp:ExactlyOne>
<sp:HttpBasicAuthentication />
<sp:RequireClientCertificate />
</wsp:ExactlyOne>
</wsp:Policy>
</sp:HttpsToken>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<wsp:ExactlyOne>
<sp:Basic256 />
<sp:Basic192 />
<sp:Basic128 />
<sp:TripleDes />
<sp:Basic256Rsa15 />
<sp:Basic192Rsa15 />
<sp:Basic128Rsa15 />
<sp:TripleDesRsa15 />
<sp:Basic256Sha256 />
<sp:Basic192Sha256 />
<sp:Basic128Sha256 />
<sp:TripleDesSha256 />
<sp:Basic256Sha256Rsa15 />
<sp:Basic192Sha256Rsa15 />
<sp:Basic128Sha256Rsa15 />
<sp:TripleDesSha256Rsa15 />
</wsp:ExactlyOne>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict />
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</wsdl:definitions>
Based on your wsdl it looks like your return is XML and not an object (I didn't see a data contract). Since the response is XML, you cannot refer directly to the response variable with dot-notation. You need to first parse the response into an object you can understand and inspect.
Have you set a break-point on var response to see if it is a string containing the XML?
You can do something like this and immediately access nodes of the response using xpath:
var response = new XmlDocument();
response.LoadXml(client.ExampleService_Test(request));
var errorMsg = response.SelectSingleNode("//Response_MT/errorMsg");
I'm using MS wsdl.exe to generate C# file from a WSDL file, but get a error describes that "the element attribute is required for headers when Use=Literal"
How can I get rid of this? Is there any other tools to generate C# from wsdl?
<message name="SomeHeader">
<part name="Version" type="xsd:string"/>
</message>
....
<operation name="xxxxx">
<soap:operation soapAction="xxxx"/>
<input>
<soap:header use="literal" message="SomeHeader" part="Version" />
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
I finally resolved this issue by replace "type" with "element".
Modified above wsdl to
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tempuri.org/"
elementFormDefault="qualified">
<xsd:element name="Version" type="xsd:string"/>
....
....
</xsd:schema>
</wsdl:types>
<message name="SomeHeader">
<part name="Version" element="tns:Version"/>
</message>
I added a service reference in Visual Studio 2010 using following wsdl. It is added successfully. This is a wsdl generated from schema xsd files; not from actual service code. Any idea why this is not generating the required class and methods in Reference.cs file?
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:import0="urn:thinktecture-com:demos:restaurantservice:messages:v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:import1="urn:thinktecture-com:demos:restaurantservice:data:v1" xmlns:tns="urn:lijo:demos:multiplyservice:calculation:v1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="CalculationService" targetNamespace="urn:lijo:demos:multiplyservice:calculation:v1" xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<types>
<xsd:schema>
<xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantMessages.xsd" namespace="urn:thinktecture-com:demos:restaurantservice:messages:v1" />
<xsd:import schemaLocation="C:\toolbox\LijosServiceApp\NewService\RestaurantData.xsd" namespace="urn:thinktecture-com:demos:restaurantservice:data:v1" />
</xsd:schema>
</types>
<message name="getMultipliedIn">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="parameters" element="import0:getMultiplied" />
</message>
<message name="getMultipliedOut">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<part name="parameters" element="import0:getMultipliedResponse" />
</message>
<portType name="CalculationServiceInterface">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<operation name="getMultiplied">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
<input message="tns:getMultipliedIn" />
<output message="tns:getMultipliedOut" />
</operation>
</portType>
<binding name="BasicHttpBinding_CalculationServiceInterface" type="tns:CalculationServiceInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getMultiplied">
<soap:operation soapAction="urn:lijo:demos:multiplyservice:calculation:v1:getMultipliedIn" style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="CalculationServicePort">
<port name="CalculationServicePort" binding="tns:BasicHttpBinding_CalculationServiceInterface">
<soap:address location="http://localhost/CalculationService" />
</port>
</service>
</definitions>
The issue was with incorrect xml namespace used by the tool. Please see the corrected wsdl in 400 Bad Request Exception: Simple SOAP WCF service with small data
The last couple of hours I've been struggling with importing a WSDL webservice into Visual Studio 2010. Slowly I've been struggling through my WSDL, solving other problems untill I encountered this one:
Warning 1 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:
System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Schema with target namespace 'urn:WebService' could not be found.
XPath to Error Source:
//wsdl:definitions[#targetNamespace='urn:WebService']/wsdl:portType[#name='DataPort']
C:\* blablabla *\WeGotchaService\Reference.svcmap 1 1 Gotcha!
I've tried every tiny little thing Google could provide me with including:
Disable 'Reuse types in referenced assemblies'
Set Collection type to system.collections.generic.list
Changing a large part of the attributes back and forth.
Copying a WSDL file from someone else, just to see if it would work (it didn't)
Here is my .wsdl file:
<?xml version="1.0"?>
<definitions
name="WebService"
targetNamespace="urn:WebService"
xmlns:tns="urn:WebService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="GetData">
<xsd:element name="getCustomerID" type="xsd:int" />
<xsd:element name="DataResponse" type="xsd:string" />
</xsd:schema>
</types>
<message name="doGetCustomerID">
<part name="ID" type="tns:getCustomerID" />
</message>
<message name="doDataResponse">
<part name="return" type="tns:DataResponse" />
</message>
<portType name="DataPort">
<operation name="getData">
<input message="tns:doGetCustomerID" />
<output message="tns:doDataResponse" />
</operation>
</portType>
<binding name="DataBinding" type="tns:DataPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getData">
<soap:operation soapAction="urn:getDataAction" />
<input>
<soap:body use="encoded" namespace="urn:GetData" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:GetData" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="WeGotchaService">
<port name="DataPort" binding="tns:DataBinding">
<soap:address location="http://localhost/weGotcha/servicehandler.php" />
</port>
</service>
</definitions>
Servicehandler.php
<?php
if(!extension_loaded("soap"))
{
dl("php_soap.dll");
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("getPersonen.wsdl");
function getData($persoon_id)
{
mysql_connect("localhost", "root", "");
mysql_select_db('gotcha_dbtemplate');
$sql = "SELECT * FROM lessen";
$sql = mysql_query($sql);
while($row = mysql_fetch_array($sql))
{
$result[] = $row;
}
mysql_close();
return $result;
}
$server->addFunction("getData");
$server->handle();
?>
I don't know how to fix this. There are some other errors but these are due to the fact that it has trouble importing the portType (binding import error because portType is not okay, port error because dependant on binding)
I hope someone knows what the problem is, I don't :(
Thanks.
Update: my test.php does work okay and it does output the results from the getData method.
I've changed so much I can't exactly remember, now it works:
<?xml version="1.0"?>
<definitions xmlns:tns="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="WebService" targetNamespace="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl">
<types>
<xs:schema elementFormDefault="qualified" targetNamespace="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://localhost/weGotcha/servicehandler/wsdl_service.wsdl">
<xsd:element name="getCustomerID" type="xsd:int"/>
<xs:complexType name="Persoon">
<xs:sequence>
<xs:element name="ID" type="xsd:int"/>
<xs:element name="Voornaam" type="xsd:string"/>
<xs:element name="Achternaam" type="xsd:string"/>
<xs:element name="Adres" type="xsd:string"/>
<xs:element name="Postcode" type="xsd:string"/>
<xs:element name="Woonplaats" type="xsd:string"/>
<xs:element name="Email_adres" type="xsd:string"/>
<xs:element name="Telefoonnummer" type="xsd:string"/>
<xs:element name="CBR_Kandidaatnummer" type="xsd:string"/>
<xs:element name="Rijbewijs" type="xsd:int"/>
<xs:element name="Laatste_keer_bewerkt" type="xsd:dateTime"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PersoonList">
<xs:complexContent>
<xs:restriction base="soapenc:Array">
<xs:sequence>
<xs:element name="Persoon" type="tns:Persoon" maxOccurs="unbounded"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
</types>
<message name="doGetCustomerID">
<part name="CustomerID" type="xsd:int"/>
</message>
<message name="doGetPersoonDataResponse">
<part name="return" type="tns:PersoonList"/>
</message>
<portType name="DataPort">
<operation name="getPersoonData">
<input message="tns:doGetCustomerID"/>
<output message="tns:doGetPersoonDataResponse"/>
</operation>
</portType>
<binding name="DataBinding" type="tns:DataPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getPersoonData">
<soap:operation soapAction="urn:getDataAction"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:GetData"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:GetData"/>
</output>
</operation>
</binding>
<service name="WeGotchaService">
<port name="DataPort" binding="tns:DataBinding">
<soap:address location="http://localhost/weGotcha/servicehandler/servicehandler.php"/>
</port>
</service>
enter code here I am trying to call a web service from a c# client. I found out that we can use SoapSender and SoapReceiver classes. please refer below for web service's WSDL
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="WelcomeService" targetNamespace="http://test/">
<types>
<xs:schema xmlns:tns="http://test/" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test/" version="1.0">
<xs:element name="WelcomeMessage" type="tns:WelcomeMessage"/>
<xs:element name="WelcomeMessageResponse" type="tns:WelcomeMessageResponse"/>
<xs:complexType name="WelcomeMessage">
<xs:sequence>
<xs:element minOccurs="0" name="message" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="WelcomeMessageResponse">
<xs:sequence/>
</xs:complexType>
</xs:schema>
</types>
<message name="Welcome_WelcomeMessageResponse">
<part element="tns:WelcomeMessageResponse" name="WelcomeMessageResponse"/>
</message>
<message name="Welcome_WelcomeMessage">
<part element="tns:WelcomeMessage" name="WelcomeMessage"/>
</message>
<portType name="Welcome">
<operation name="WelcomeMessage" parameterOrder="WelcomeMessage">
<input message="tns:Welcome_WelcomeMessage"/>
<output message="tns:Welcome_WelcomeMessageResponse"/>
</operation>
</portType>
<binding name="WelcomeBinding" type="tns:Welcome">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="WelcomeMessage">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="WelcomeService">
<port binding="tns:WelcomeBinding" name="WelcomePort">
<soap:address location="http://127.0.0.1:8080/SoapSeam/Welcome"/>
</port>
</service>
</definitions>
I am having hard time to figure out how to populate Soap envelope object.
You must have found old or bad information on the web. See How to Consume a Web Service for current information.
Also, see wcf. WCF is the technology you should use to work with SOAP web services.