WCF client receiving response with null value even though response has data - c#

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");

Related

Convert WSE3 Web Service Client Code to WCF

Convert WSE3 Web Service Client Code to WCF
Hi. It would be much appreciated if an expert could be able to convert the following WSE3 web service client code to some working(well as much as possible) WCF code(preferable with configuration in code and entire code as short as can be) please? I've seen some examples using the ChannelFactory class but there may be a cleaner/shorter way.
The 3rd Party web service being called is: HTTPS, EndPoint is ASMX file, SOAP 1.1, and using ws-security. The working WSE3 code is:
Dim ExpCertificate As New X509Certificate2
ExpCertificate = New X509Certificate2("<pfx file>", "<password>")
Dim waspservice As New TokenService
waspservice.ClientCertificates.Add(ExpCertificate)
waspservice.Url = "https://somesite.asmx"
Dim res As String = waspservice.STS("<WASPAuthenticationRequest><ApplicationName>Example Client</ApplicationName><AuthenticationLevel>CertificateAuthentication</AuthenticationLevel><AuthenticationParameters/></WASPAuthenticationRequest>")
Response.Write(res & vbCrLf & vbCrLf)
An example soap request is:
<wsse:Security>
<wsu:Timestampwsu:Id="Timestamp-2b27a32b-ca9c-4405-b377-4444f63c8f29">
<wsu:Created>2011-02-20T16:36:54Z</wsu:Created>
<wsu:Expires>2011-02-20T16:41:54Z</wsu:Expires>
</wsu:Timestamp>
<wsse:BinarySecurityToken ValueType="CompanyWASP" EncodingType="wsse:Base64Binary" wsu:Id="SecurityToken-f64439f9-c12c-4d09-ac3d-fc478ad19775">MjAtRTctQ0YtMTUtN0EtODEtNTk.</wsse:BinarySecurityToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<! -- SOAP content for the service call -- >
</soap:Body>
The WSDL is:
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.uk.company.com/WASP/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www.uk.company.com/WASP/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.uk.company.com/WASP/">
<s:element name="STS">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="authenticationBlock" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="STSResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="STSResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" nillable="true" type="s:string" />
</s:schema>
</wsdl:types>
<wsdl:message name="STSSoapIn">
<wsdl:part name="parameters" element="tns:STS" />
</wsdl:message>
<wsdl:message name="STSSoapOut">
<wsdl:part name="parameters" element="tns:STSResponse" />
</wsdl:message>
<wsdl:message name="STSHttpGetIn">
<wsdl:part name="authenticationBlock" type="s:string" />
</wsdl:message>
<wsdl:message name="STSHttpGetOut">
<wsdl:part name="Body" element="tns:string" />
</wsdl:message>
<wsdl:message name="STSHttpPostIn">
<wsdl:part name="authenticationBlock" type="s:string" />
</wsdl:message>
<wsdl:message name="STSHttpPostOut">
<wsdl:part name="Body" element="tns:string" />
</wsdl:message>
<wsdl:portType name="TokenServiceSoap">
<wsdl:operation name="STS">
<wsdl:input message="tns:STSSoapIn" />
<wsdl:output message="tns:STSSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="TokenServiceHttpGet">
<wsdl:operation name="STS">
<wsdl:input message="tns:STSHttpGetIn" />
<wsdl:output message="tns:STSHttpGetOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="TokenServiceHttpPost">
<wsdl:operation name="STS">
<wsdl:input message="tns:STSHttpPostIn" />
<wsdl:output message="tns:STSHttpPostOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TokenServiceSoap" type="tns:TokenServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="STS">
<soap:operation soapAction="http://www.uk.company.com/WASP/STS" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TokenServiceHttpGet" type="tns:TokenServiceHttpGet">
<http:binding verb="GET" />
<wsdl:operation name="STS">
<http:operation location="/STS" />
<wsdl:input>
<http:urlEncoded />
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TokenServiceHttpPost" type="tns:TokenServiceHttpPost">
<http:binding verb="POST" />
<wsdl:operation name="STS">
<http:operation location="/STS" />
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded" />
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TokenService">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/">company Token Service</documentation>
<wsdl:port name="TokenServiceSoap" binding="tns:TokenServiceSoap">
<soap:address location="https://secure.authenticator.uat.uk.company.com/WaspAuthenticator/TokenService.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Generate proxy class either of using
wsdl.exe OR by adding service reference in visual studio. That will create required proxy.
Proxy will have methods which you want to call. Pass in required parameters and you should be good.

How to assign values to method params of Imported WSDL

In a C# 2008 application I am getting the error message "Object reference not set to an instance of an object."
The line of code that is causing this to occur is the following:
insert.forminputdata.freeformcontrols.PrimaryAccID.Value = "24";
I have a method in wsdl which takes the input request as follows.
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<CreateTransaction xmlns="http://schemas.cordys.com/default">
<ns0:forminputdata xmlns:ns0="http://schemas.cordys.com/1.0/xforms/processapi">
<ns0:freeformcontrols>
<ns0:PrimaryAccID display_name="Primary Acc ID">PARAMETER</ns0:PrimaryAccID>
<ns0:SecondaryAccID display_name="Secondary Acc ID">PARAMETER</ns0:SecondaryAccID>
</ns0:freeformcontrols>
</ns0:forminputdata>
</CreateTransaction>
</SOAP:Body>
The complete wsdl is
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tns="http://schemas.cordys.com/default" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="ExecuteBPM.ExecuteTransaction" targetNamespace="http://schemas.cordys.com/default" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://schemas.cordys.com/1.0/xforms/processapi" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.cordys.com/default" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://schemas.cordys.com/1.0/xforms/processapi" />
<xsd:import namespace="http://schemas.cordys.com/bpm/instance/1.0" />
<xsd:import namespace="http://schemas.cordys.com/1.0/xforms/processapi" />
<xsd:element name="CreateTransaction">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns1:forminputdata" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CreateTransactionResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="data">
<xsd:complexType>
<xsd:all>
<xsd:element name="instance_id">
<xsd:annotation>
<xsd:documentation>This output parameter contains the unique instance identifier for the business-process.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="PAGEFLOWDATA">
<xsd:annotation>
<xsd:documentation>This optional output parameter contains the response message from the business-process and this is available only in case of page flow processes.</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded" processContents="skip" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.cordys.com/bpm/instance/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://schemas.cordys.com/1.0/xforms/processapi" />
<xsd:element name="headerInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="target" type="xsd:string" />
<xsd:element name="source">
<xsd:complexType>
<xsd:attribute name="type" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="bpm">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="instance_id" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.cordys.com/1.0/xforms/processapi" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="forminputdata">
<xsd:complexType>
<xsd:all>
<xsd:element name="freeformcontrols">
<xsd:complexType>
<xsd:all>
<xsd:element name="PrimaryAccID">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute default="Primary Acc ID" name="display_name" type="xsd:string" use="optional" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="SecondaryAccID">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute default="Secondary Acc ID" name="display_name" type="xsd:string" use="optional" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" name="CreateTransactionInput">
<wsdl:part name="body" element="tns:CreateTransaction" />
</wsdl:message>
<wsdl:message xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" name="CreateTransactionOutput">
<wsdl:part name="body" element="tns:CreateTransactionResponse" />
</wsdl:message>
<wsdl:message xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" name="HeaderOutput">
<wsdl:part name="BPMHeaderOutput" element="inst:bpm" />
</wsdl:message>
<wsdl:portType xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" name="ExecuteTransaction">
<wsdl:operation name="CreateTransaction">
<wsdl:input message="tns:CreateTransactionInput" />
<wsdl:output message="tns:CreateTransactionOutput" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" name="ExecuteTransaction" type="tns:ExecuteTransaction">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="CreateTransaction">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
<soap:header message="tns:HeaderOutput" part="BPMHeaderOutput" use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service xmlns:inst="http://schemas.cordys.com/bpm/instance/1.0" name="ExecuteTransactionService">
<wsdl:port name="ExecuteTransactionPort" binding="tns:ExecuteTransaction">
<soap:address location="http://srv-ind-dvm28aw/cordys/com.eibus.web.soap.Gateway.wcp?organization=o=ewm,cn=cordys,cn=EWM_CU6,o=vanenburg.com&SAMLart=MDFgZEgICDQ+u+3viuskQtM5/APNP1YhIhFVVVo/fvRCxKezFVk1Ltvx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
In the .cs file I am trying to set these params like
using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data;
using System.Xml;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service()
{
}
srv_ind_dvm28aw.ExecuteTransactionService soapClient = new srv_ind_dvm28aw.ExecuteTransactionService();
[WebMethod]
public void Transaction()
{
srv_ind_dvm28aw.CreateTransaction insert = new srv_ind_dvm28aw.CreateTransaction();
srv_ind_dvm28aw.CreateTransactionResponse response = new srv_ind_dvm28aw.CreateTransactionResponse();
try
{
insert.forminputdata.freeformcontrols.PrimaryAccID.Value = "24";
insert.forminputdata.freeformcontrols.SecondaryAccID.Value = "22";
response = soapClient.CreateTransaction(insert);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Without using the set param lines, I could successfully call the method (ie without the following couple of lines)
insert.forminputdata.freeformcontrols.PrimaryAccID.Value = "24";
insert.forminputdata.freeformcontrols.SecondaryAccID.Value = "22";
Is this my way of setting param to the soap method is correct ?Please guide me where I am going wrong.
The exact error throws at insert.forminputdata is null.
You need to initialize the objects. It should be something like this:
insert.forminputdata = new forminputdata();
insert.forminputdata.freeformcontrols = new forminputdataFreeformcontrols();
insert.forminputdata.freeformcontrols.PrimaryAccID = new forminputdataFreeformcontrolsPrimaryAccID();
insert.forminputdata.freeformcontrols.PrimaryAccID.Value = "24";

Manual configuration of service reference

When I add a Service reference in visual studio 2012 it adds these attributes for ordering elements to all my properties to my reference.cs.
[System.Xml.Serialization.XmlArrayAttribute(Order=0)]
However it causes the soap message to not de-serialize correctly.
When I remove them it works.
So I need to know how to generate the reference.cs without the attributes through some config or whatever it takes.
I looked at the Reference.svcmap map but do not see a setting in their for this particular problem.
I tried MSDN but cannot find anything on manual configuration for this type of request.
Note if I add it as a web reference it will not add those attributes but do not want that route as I want the aync processing.
Please help!
Note: server web service is a 3rd party and is an apache axis hosted service.
Here is the wsdl:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:prews="http://www.coda.com/efinance/schemas/presenter/presenter-11.1/webservice" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://www.coda.com/efinance/schemas/presenter/presenter-11.1/webservice">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:com="http://www.coda.com/efinance/schemas/common" xmlns:pre="http://www.coda.com/efinance/schemas/presenter" targetNamespace="http://www.coda.com/efinance/schemas/presenter/presenter-11.1/webservice" attributeFormDefault="unqualified" elementFormDefault="qualified">
<xsd:import namespace="http://www.coda.com/efinance/schemas/common" schemaLocation="http://sfdcoda1/coda/wsdl/finance/common/common.xsd"/>
<xsd:import namespace="http://www.coda.com/efinance/schemas/presenter" schemaLocation="http://sfdcoda1/coda/wsdl/finance/presenter/presenter.xsd"/>
<xsd:element name="AddRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Companies" minOccurs="0" type="com:Companies"/>
<xsd:element name="Presenter" type="pre:Presenter">
<xsd:annotation>
<xsd:documentation>
Contains the information for the presenter master you want to create.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ListRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Filter" type="pre:PresenterListFilter">
<xsd:annotation>
<xsd:documentation>
A filter that selects the presenter masters to be listed.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CmpCode" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code of the company in which you attempted to retrieve the presenter master.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Code" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code of the presenter master that you attempted to retrieve.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Presenter" minOccurs="0" type="pre:Presenter">
<xsd:annotation>
<xsd:documentation>
Contains the presenter master you have retrieved from the database.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="OptionsResponse">
<xsd:complexType>
<xsd:attribute name="transactioncoordinator" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="ListResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Filter" type="pre:PresenterListFilter">
<xsd:annotation>
<xsd:documentation>
The filter that was used to select the presenter masters to be listed.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Keys" minOccurs="0" type="com:KeyData">
<xsd:annotation>
<xsd:documentation>
Contains the key information for the listed presenter masters.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeleteResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CmpCode" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code of the company in which you attempted to delete the presenter master.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Code" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code of the presenter master that you attempted to delete.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="UpdateResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MultiCompany" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Companies" type="com:Companies"/>
<xsd:element name="Warning" type="com:Reason"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CmpCode" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code for the company in which you attempted to update the presenter master.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Code" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code of the presenter master that you attempted to update.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="TimeStamp" type="com:typeWord">
<xsd:annotation>
<xsd:documentation>
The TimeStamp value for this presenter master in the database.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AddResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MultiCompany" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Companies" type="com:Companies"/>
<xsd:element name="Warning" type="com:Reason"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CmpCode" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code of the company in which you attempted to create the presenter master.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Code" type="com:typeGeneralCode">
<xsd:annotation>
<xsd:documentation>
The code of the presenter master that you attempted to create.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="TimeStamp" type="com:typeWord">
<xsd:annotation>
<xsd:documentation>
The TimeStamp value for this presenter master in the database.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="UpdateRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Companies" minOccurs="0" type="com:Companies"/>
<xsd:element name="Presenter" type="pre:Presenter">
<xsd:annotation>
<xsd:documentation>
Contains the information for the presenter master you want to update.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Options">
<xsd:complexType>
<xsd:attribute name="bulkload" type="xsd:boolean"/>
<xsd:attribute name="logtitle" type="com:typeLogTitle"/>
<xsd:attribute name="attachments" type="com:typeAttachments" default="none"/>
<xsd:attribute name="locale" type="com:typeLocale"/>
<xsd:attribute name="origin" type="xsd:string"/>
<xsd:attribute name="user" type="com:typeGeneralCode"/>
<xsd:attribute name="company" type="com:typeGeneralCode"/>
<xsd:attribute name="session" type="xsd:string"/>
<xsd:attribute name="slot" type="xsd:nonNegativeInteger"/>
<xsd:attribute name="transactionid" type="xsd:string"/>
<xsd:attribute name="txtimeout" type="xsd:int"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeleteRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Key" type="com:Key">
<xsd:annotation>
<xsd:documentation>
Contains the key identifying the presenter master you want to delete.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Key" type="com:Key">
<xsd:annotation>
<xsd:documentation>
Contains the key identifying the presenter masters you want to retrieve from the database.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="UpdateResponse">
<part name="UpdateResponse" element="prews:UpdateResponse"/>
</message>
<message name="GetRequest">
<part name="GetRequest" element="prews:GetRequest"/>
</message>
<message name="Options">
<part name="Options" element="prews:Options"/>
</message>
<message name="AddResponse">
<part name="AddResponse" element="prews:AddResponse"/>
</message>
<message name="GetResponse">
<part name="GetResponse" element="prews:GetResponse"/>
</message>
<message name="DeleteResponse">
<part name="DeleteResponse" element="prews:DeleteResponse"/>
</message>
<message name="DeleteRequest">
<part name="DeleteRequest" element="prews:DeleteRequest"/>
</message>
<message name="AddRequest">
<part name="AddRequest" element="prews:AddRequest"/>
</message>
<message name="ListResponse">
<part name="ListResponse" element="prews:ListResponse"/>
</message>
<message name="ListRequest">
<part name="ListRequest" element="prews:ListRequest"/>
</message>
<message name="OptionsResponse">
<part name="OptionsResponse" element="prews:OptionsResponse"/>
</message>
<message name="UpdateRequest">
<part name="UpdateRequest" element="prews:UpdateRequest"/>
</message>
<portType name="PresenterServicePortTypes">
<operation name="Update">
<input message="prews:UpdateRequest"/>
<output message="prews:UpdateResponse"/>
</operation>
<operation name="Add">
<input message="prews:AddRequest"/>
<output message="prews:AddResponse"/>
</operation>
<operation name="Get">
<input message="prews:GetRequest"/>
<output message="prews:GetResponse"/>
</operation>
<operation name="Delete">
<input message="prews:DeleteRequest"/>
<output message="prews:DeleteResponse"/>
</operation>
<operation name="List">
<input message="prews:ListRequest"/>
<output message="prews:ListResponse"/>
</operation>
</portType>
<binding name="PresenterServiceSOAPBinding" type="prews:PresenterServicePortTypes">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Update">
<documentation>
Updates presenter masters in the database using the information you provide.
</documentation>
<soap:operation soapAction="uri-coda-webservice/11.300.0491/finance/Presenter/Update" style="document"/>
<input>
<soap:header message="prews:Options" part="Options" use="literal"></soap:header>
<soap:body use="literal"/>
</input>
<output>
<soap:header message="prews:OptionsResponse" part="OptionsResponse" use="literal"></soap:header>
<soap:body use="literal"/>
</output>
</operation>
<operation name="Add">
<documentation>
Creates new presenter masters in the database using the information you provide.
</documentation>
<soap:operation soapAction="uri-coda-webservice/11.300.0491/finance/Presenter/Add" style="document"/>
<input>
<soap:header message="prews:Options" part="Options" use="literal"></soap:header>
<soap:body use="literal"/>
</input>
<output>
<soap:header message="prews:OptionsResponse" part="OptionsResponse" use="literal"></soap:header>
<soap:body use="literal"/>
</output>
</operation>
<operation name="Get">
<documentation>
Retrieves the specified presenter masters from the database.
</documentation>
<soap:operation soapAction="uri-coda-webservice/11.300.0491/finance/Presenter/Get" style="document"/>
<input>
<soap:header message="prews:Options" part="Options" use="literal"></soap:header>
<soap:body use="literal"/>
</input>
<output>
<soap:header message="prews:OptionsResponse" part="OptionsResponse" use="literal"></soap:header>
<soap:body use="literal"/>
</output>
</operation>
<operation name="Delete">
<documentation>
Deletes the specified presenter master from the database.
</documentation>
<soap:operation soapAction="uri-coda-webservice/11.300.0491/finance/Presenter/Delete" style="document"/>
<input>
<soap:header message="prews:Options" part="Options" use="literal"></soap:header>
<soap:body use="literal"/>
</input>
<output>
<soap:header message="prews:OptionsResponse" part="OptionsResponse" use="literal"></soap:header>
<soap:body use="literal"/>
</output>
</operation>
<operation name="List">
<documentation>
Retrieves key information for the specified presenter masters from the database.
</documentation>
<soap:operation soapAction="uri-coda-webservice/11.300.0491/finance/Presenter/List" style="document"/>
<input>
<soap:header message="prews:Options" part="Options" use="literal"></soap:header>
<soap:body use="literal"/>
</input>
<output>
<soap:header message="prews:OptionsResponse" part="OptionsResponse" use="literal"></soap:header>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="PresenterService">
<port name="PresenterServicePort" binding="prews:PresenterServiceSOAPBinding">
<soap:address location="http://sfdcoda1/coda/services/finance/presenter/presenter-11.1"/>
</port>
</service>
</definitions>
Try removing the order attribute from the DataContract attributes. Then when you use Service Reference, it should not add the order attribute there also.
You must be doing something like:
[DataContract]
public class DerivedType : BaseType
{
[DataMember(Order = 0)]
public string bird;
[DataMember(Order = 1)]
public string parrot;
}
Just remove the Order attributes in your contracts.

Cannot import WSDL service "targetNamespace 'urn:webservice' not found'

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>

c# web service consumption error

Im trying to consume a web service using the below WSDL from a .NET C# project.
I've added the web reference etc and tried invoking the method (getPatients) but it always returns an error:
"MyService.PatientType[] PatientService.getPatients(MyService.getPatients getPatients1)"
"No overload for method 'getPatients' takes 0 arguments"
I thought my code was ok (same as I've used successfully before) but I must be doing something wrong...
MyService.PatientService ws = new MyService.PatientService();
string message = ws.getPatients();
Does anyone have any ideas?
Thanks
WSDL:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="patient"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/patientservice/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:p1="http://www.example.org/patientservice/patient_types/"
targetNamespace="http://www.example.org/patientservice/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/patientservice/patient_types/"
xmlns:tns="http://www.example.org/patientservice/patient_types/"
xmlns:ns1="http://www.example.org/patient"
elementFormDefault="qualified">
<xsd:complexType name="patientType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="age" type="xsd:int"/>
<xsd:element name="ssn" type="xsd:string"/>
<xsd:element name="pid" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getPatients">
<xsd:complexType/>
</xsd:element>
<xsd:element name="getPatientsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="patient" type="tns:patientType" maxOccurs="unbounded" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getPatient">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ssn" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getPatientResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="patient" type="tns:patientType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getPatientsRequest">
<wsdl:part element="p1:getPatients" name="in"/>
</wsdl:message>
<wsdl:message name="getPatientsResponse">
<wsdl:part element="p1:getPatientsResponse" name="out"/>
</wsdl:message>
<wsdl:message name="getPatientRequest">
<wsdl:part name="in" element="p1:getPatient"></wsdl:part>
</wsdl:message>
<wsdl:message name="getPatientResponse">
<wsdl:part name="out" element="p1:getPatientResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="patient">
<wsdl:operation name="getPatients">
<wsdl:input message="tns:getPatientsRequest"/>
<wsdl:output message="tns:getPatientsResponse"/>
</wsdl:operation>
<wsdl:operation name="getPatient">
<wsdl:input message="tns:getPatientRequest"></wsdl:input>
<wsdl:output message="tns:getPatientResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="patientSOAP" type="tns:patient">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getPatients">
<soap:operation style="document" soapAction=""/>
<wsdl:input name="getPatientsRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getPatientsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getPatient">
<soap:operation style="document" soapAction=""/>
<wsdl:input name="getPatientRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getPatientResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PatientService">
<wsdl:port binding="tns:patientSOAP" name="PatientSOAPPort">
<soap:address location="http://192.168.100.1:8080/patientservice"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I've generated a proxy against the wsdl and it seems the method getPatients takes a parameter.
try this:
PatientService ws = new PatientService();
getPatients getPatients1 = new getPatients();
patientType[] patients = ws.getPatients(getPatients1);

Categories

Resources