How to assign values to method params of Imported WSDL - c#

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

Related

How to get key value pairs from resx file using powershell script?

I need to obtain values from c# resx file using powershell script.Is it possible to obtain these xml values using only PS scripting?I wrote a code only in PS but it didn't work.Snippets would help!!
Using ResXResourceSet Class:
$File = 'c:\path\to\file.resx'
# Add assembly containing class, not sure if needed, but wouldn't hurt
Add-Type -AssemblyName System.Windows.Forms
# Create new ResXResourceSet, pass path to the resx file to the constructor
$ResourceSet = New-Object -TypeName 'System.Resources.ResXResourceSet' -ArgumentList $File
# Get resources
$ResourceSet.GetString('TestString')
$ResourceSet.GetString('AnotherTestString')
ResX example:
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="TestString" xml:space="preserve">
<value>This is some test string...</value>
</data>
<data name="AnotherTestString" xml:space="preserve">
<value>Another test string...</value>
</data>
</root>
Output:
This is some test string...
Another test string...
P.S.
ResX files are XML, so you can get values from them using XPath or other methods.
References:
How to clean up resx files with PowerShell

.NET consume SAP web service

I'm trying to figure out how to consume a SAP webservice. I have a .WSDL file which looks for certain info in SAP.
My .WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="Customer_Out" targetNamespace="..." xmlns:p1="...." 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" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation/>
<wsp:UsingPolicy wsdl:required="true"/>
<wsp:Policy wsu:Id="OP_CustomerRead_sync"/>
<wsdl:types>
<xsd:schema targetNamespace="..." xmlns="..." xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="MT_CustomerRead_response" type="DT_CustomerRead_response"/>
<xsd:element name="FMT_Customer">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="standard" type="ExchangeFaultData"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="MT_CustomerRead_request" type="DT_CustomerRead_request"/>
<xsd:complexType name="ExchangeFaultData">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">..</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="faultText" type="xsd:string"/>
<xsd:element name="faultUrl" type="xsd:string" minOccurs="0"/>
<xsd:element name="faultDetail" type="ExchangeLogData" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_Customer">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="BpId" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Name" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="AccountGroup" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Street" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Number" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="City" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Country" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Region" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_CustomerRead_request">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="RowLimit" type="xsd:integer"/>
<xsd:element name="BpId" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Name" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="ExternalCustomer" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="AccountGroup" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ExchangeLogData">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="severity" type="xsd:string" minOccurs="0"/>
<xsd:element name="text" type="xsd:string"/>
<xsd:element name="url" type="xsd:string" minOccurs="0"/>
<xsd:element name="id" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DT_CustomerRead_response">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">...</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Customer" type="DT_Customer" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">...</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Remark" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MT_CustomerRead_request">
<wsdl:documentation/>
<wsdl:part name="MT_CustomerRead_request" element="p1:MT_CustomerRead_request"/>
</wsdl:message>
<wsdl:message name="MT_CustomerRead_response">
<wsdl:documentation/>
<wsdl:part name="MT_CustomerRead_response" element="p1:MT_CustomerRead_response"/>
</wsdl:message>
<wsdl:message name="FMT_Customer">
<wsdl:documentation/>
<wsdl:part name="FMT_Customer" element="p1:FMT_Customer"/>
</wsdl:message>
<wsdl:portType name="Customer_Out">
<wsdl:documentation/>
<wsdl:operation name="CustomerRead_sync">
<wsdl:documentation/>
<wsp:Policy>
<wsp:PolicyReference URI="#OP_CustomerRead_sync"/>
</wsp:Policy>
<wsdl:input message="p1:MT_CustomerRead_request"/>
<wsdl:output message="p1:MT_CustomerRead_response"/>
<wsdl:fault name="FMT_Customer" message="p1:FMT_Customer"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Customer_OutBinding" type="p1:Customer_Out">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:operation name="CustomerRead_sync">
<soap:operation soapAction="http://sap.com/xi/WebService/soap1.1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:input>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:output>
<wsdl:fault name="FMT_Customer">
<soap:fault use="literal" name="FMT_Customer" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Customer_OutService">
<wsdl:port name="HTTP_Port" binding="p1:Customer_OutBinding">
<soap:address location="..." xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I've added a Service Reference to my .NET project which references the .WSDL file. This creates a namespace which allows me to make an instance of a couple of classes (9 in total).
I can't seem to find how to pass the request and receive the corresponding response. Should I parse these requests/responses? I'm aware of this tutorial but it doesn't really correspond with the file which I'm dealing with.
A request looks like this:
<man:MT_CustomerRead_request>
<RowLimit>100</RowLimit>
<!--Optional:-->
<!-- <CustomerId>?
<!--Optional:-->
<Name>Dell*</Name>
<!--Optional:-->
<!--Optional:-->
<AccountGroup>ABC</AccountGroup>
</man:MT_CustomerRead_request>
Thanks in advance
I'm just working on this topic and here's an example on how to create a request and call the SAP service in .NET (C#).
// Create the client
SapServiceReference.ECC_WS sapService = new SapServiceReference.ECC_WS();
sapService.Credentials = new NetworkCredential("Account", "Password");
// Prepare the parameters
SapServiceReference._parameters param = new SapServiceReference._parameters();
param.id = 1;
param.action = "R";
// Call SAP service
SapServiceReference._ws_Response response = sapService._someFunction(param);
string result = response.EvDescriptionText.Tdline;

How do XML Schema namespaces map to C# class namespaces?

For an XSD document such as this, say I was to create a C# class using some tool like xsd.exe or xsd2code, How do I define the namespace each class belongs to? Or do they all belong to only one namespace?
?xml version="1.0" encoding="UTF-8"?><xsd:schema targetNamespace="http://com.ibm.wbit.comptest.controller"
xmlns:Q1="http://com.ibm.wbit.comptest.controller" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="TestResults">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="testSuites" type="Q1:TestSuiteRun"/>
</xsd:sequence>
<xsd:attribute name="testProject" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="TestSuiteRun">
<xsd:complexContent>
<xsd:extension base="Q1:TestRun">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="testCases" type="Q1:TestCaseRun">
</xsd:element>
</xsd:sequence>
<xsd:attribute name="tests" type="xsd:int"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="TestCaseRun">
<xsd:complexContent>
<xsd:extension base="Q1:TestRun">
<xsd:sequence>
<xsd:element name="result" type="Q1:Severity"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="variations" type="Q1:VariationRun">
</xsd:element>
</xsd:sequence>
<xsd:attribute name="variationCount" type="xsd:int"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="VariationRun">
<xsd:complexContent>
<xsd:extension base="Q1:TestRun">
<xsd:sequence>
<xsd:element name="result" type="Q1:Severity"/>
<xsd:element name="exception" nillable="true" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
This element is used to display the exception of a failure or error.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:simpleType name="Severity">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="pass"/>
<xsd:enumeration value="fail"/>
<xsd:enumeration value="error"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="TestRun">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="startTime" type="xsd:dateTime"/>
<xsd:attribute name="endTime" type="xsd:dateTime"/>
<xsd:attribute name="result" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>

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.

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