How can I find the parameters of a wsdl service in c# - c#

I am trying to get all parameters,methods etc of a wsdl service which there is no documentation.
The web page of the wsdl service is:
https://www1.gsis.gr/wsicisnet/MessageProcessorService?wsdl
I found that in
https://www1.gsis.gr/wsicisnet/MessageProcessorService?xsd=3
there are some attributes that are required
<xs:attribute name="traderID" type="xs:string" use="required"/>
<xs:attribute name="wsUserID" type="xs:string" use="required"/>
<xs:attribute name="wsPass" type="xs:string" use="required"/>
but when I try to send the message it gives me an error
RulesConditionasError: SubmittingTraderIdentification
([SubmittingTraderIdentification: null] must be the same as the
trader ID (801063350)
I can't find anywhere any attribute or parameter for SubmittingTraderIdentification .
Can someone help me out?
EDIT:
When I load the wsdl service in SoapUI and generate a request it look like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:icis="http://icis.externaldomain.services.ws">
<soapenv:Header/>
<soapenv:Body>
<icis:processIncomingMessageRequest>
<!--Optional:-->
<icis:messageRequest traderID="?" wsUserID="?" wsPass="?">
<DigitallySignedMessage messageType="?" isXmlString="?">
<xmlMessage>?</xmlMessage>
</DigitallySignedMessage>
</icis:messageRequest>
</icis:processIncomingMessageRequest>
</soapenv:Body>
</soapenv:Envelope>
EDIT 2:
This is the XML that I try send from my program:
<?xml version="1.0" encoding="utf-8"?>
<EF15A xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Header>
<MessageSender>TRADER.GR</MessageSender>
<MessageRecipient>NES.EL</MessageRecipient>
<DateOfPreparation>2020-10-06</DateOfPreparation>
<TimeOfPreparation>16:30:00</TimeOfPreparation>
<MessageIdentifier>20/198</MessageIdentifier>
</Header>
<Body>
<DeclarationOfExciseTaxesRegistration>
<SubmittingOperator>
<SubmittingOperatorIdentification>1234567</SubmittingOperatorIdentification>
<SubmittingTraderIdentification>1234567</SubmittingTraderIdentification>
</SubmittingOperator>
<ExciseTaxesDeclaration>
<LocalReferenceNumber>1544237495/20/198</LocalReferenceNumber>
<Fallbackflag>0</Fallbackflag>
<RegistrationOffice>GR004531</RegistrationOffice>
<DocumentState>0</DocumentState>
<DocumentNumber>1</DocumentNumber>
<TotalDocuments>1</TotalDocuments>
<NumberOfRows>1</NumberOfRows>
<DispatchCountry>BG</DispatchCountry>
<DestinationCountry>GR</DestinationCountry>
<ExistenceOfContainerFlag>0</ExistenceOfContainerFlag>
<DeliveryConditions>FCA</DeliveryConditions>
<Currency>EUR</Currency>
<InvoiceAmount>6600.00</InvoiceAmount>
<ExchangeFactor>1</ExchangeFactor>
<ChemicalAnalysisPerformedFlag>0</ChemicalAnalysisPerformedFlag>
<ThroughSimplifiedProcedureFlag>0</ThroughSimplifiedProcedureFlag>
<PaymentMethodCode>H</PaymentMethodCode>
<CertificateIssuanceFlag>1</CertificateIssuanceFlag>
<DeclarationTypeCode>30</DeclarationTypeCode>
<CalculationOfTaxesDate>2020-10-06</CalculationOfTaxesDate>
<GeneralChemistryDetails />
<DeliveryDetails>
<TransportVehicleIdentificationNumber>K4423NBA</TransportVehicleIdentificationNumber>
<TransportVehicleCountry>BG</TransportVehicleCountry>
<NationalTransportMode>3</NationalTransportMode>
</DeliveryDetails>
<ClearingAgent>
<ClearingAgentType>1</ClearingAgentType>
<ClearingAgentEORI>GR1234567</ClearingAgentEORI>
</ClearingAgent>
</ExciseTaxesDeclaration>
<ExciseTaxesDeclarationConsignor>
<ExciseTaxesDeclarationConsignorType>0</ExciseTaxesDeclarationConsignorType>
</ExciseTaxesDeclarationConsignor>
<ExciseTaxesObligee>
<ObligeeType>7</ObligeeType>
<ObligeeIdentificationType>1</ObligeeIdentificationType>
<ObligeeIdentification>1234567</ObligeeIdentification>
<ContactDetails />
</ExciseTaxesObligee>
<ExciseTaxesDeclarationConsignee>
<ConsigneeType>0</ConsigneeType>
<ConsigneeIdentificationType>1</ConsigneeIdentificationType>
<ConsigneeIdentification>1234567</ConsigneeIdentification>
<ContactDetails />
<SpecialConsignee>
<SpecialConsigneeLicenseType>1</SpecialConsigneeLicenseType>
</SpecialConsignee>
<VesselRegistrationDetails>
<VesselRegistrationType>1</VesselRegistrationType>
</VesselRegistrationDetails>
</ExciseTaxesDeclarationConsignee>
<ExciseTaxesRow>
<ExciseTaxesDeclarationRowNumber>1</ExciseTaxesDeclarationRowNumber>
<SymbolNumbers>ΔΙΠΛΟΚΑΜΠΙΝΟ ΦΟΡΤΗΓΟ FORD RANGER ΚΥΛ:2500 ΕΤΟΥΣ:2007</SymbolNumbers>
<TaricCode>8704219900</TaricCode>
<TaricAdditionCode>1901</TaricAdditionCode>
<TaxQuantity>1</TaxQuantity>
<CountryOfOrigin>SE</CountryOfOrigin>
<GrossWeight>3020.000</GrossWeight>
<NetWeight>3020.000</NetWeight>
<ConditionIdentification>48</ConditionIdentification>
<PreviousConditionIdentification>00</PreviousConditionIdentification>
<ExemptionCode>P12</ExemptionCode>
<StatisticalValue>6600.00</StatisticalValue>
<SupplementaryComputationInformation>
<SupplementaryComputationInfo>816 </SupplementaryComputationInfo>
<SupplementaryComputationValue>6600.00</SupplementaryComputationValue>
</SupplementaryComputationInformation>
<PreviousDocuments>
<PreviousDocumentType>4</PreviousDocumentType>
<PreviousAsdeDocument />
<PreviousEaadDocument />
<PreviousStampRequestDocument />
<PreviousVehicleArrivalDocument>
<DeclarationReferenceNumber>19GRVA44531810</DeclarationReferenceNumber>
</PreviousVehicleArrivalDocument>
<PreviousVehicleMovementDocument />
<PreviousExciseTaxesDeclarationDocument />
</PreviousDocuments>
<ReferenceDocuments>
<ReferenceDocumentId>1E04</ReferenceDocumentId>
<ReferenceDocumentNumber>2048764105</ReferenceDocumentNumber>
</ReferenceDocuments>
<ReferenceDocuments>
<ReferenceDocumentId>1E05</ReferenceDocumentId>
<ReferenceDocumentNumber>1018744363</ReferenceDocumentNumber>
</ReferenceDocuments>
<ReferenceDocuments>
<ReferenceDocumentId>3</ReferenceDocumentId>
<ReferenceDocumentNumber>969/2019</ReferenceDocumentNumber>
</ReferenceDocuments>
<ReferenceDocuments>
<ReferenceDocumentId>4</ReferenceDocumentId>
<ReferenceDocumentNumber>2593/2018</ReferenceDocumentNumber>
</ReferenceDocuments>
<ReferenceDocuments>
<ReferenceDocumentId>1</ReferenceDocumentId>
<ReferenceDocumentNumber>14.03.2019</ReferenceDocumentNumber>
</ReferenceDocuments>
<VehicleDetails>
<FrameNumber>WF1053539371</FrameNumber>
<CarKind>8</CarKind>
<ImporterCodeOrBrandName>13</ImporterCodeOrBrandName>
<FirstAllowanceDate>2007-12-18</FirstAllowanceDate>
<VehicleFactoryType>2AW</VehicleFactoryType>
<VehicleUsedFlag>1</VehicleUsedFlag>
<EngineCapacity>2500</EngineCapacity>
<EngineType>WL</EngineType>
<FuelType>ΠΕΤΡΕΛΑΙΟ</FuelType>
<MakeYear>2007</MakeYear>
<VehicleModelName>RANGER</VehicleModelName>
<ImportedDate>2019-02-19</ImportedDate>
<CountryLast>SE</CountryLast>
<MileageType>456</MileageType>
<CarbonDioxideEmissionsType>456</CarbonDioxideEmissionsType>
<VehicleRebateFlag>0</VehicleRebateFlag>
</VehicleDetails>
<TaxComputation>
<NationalAccountingCode>504</NationalAccountingCode>
<SuspensionFlag>0</SuspensionFlag>
<AmountOfTaxes>686.4</AmountOfTaxes>
<PaymentMethodCode>H</PaymentMethodCode>
<TaxBase>6600.00</TaxBase>
<TaxRate>10,4000</TaxRate>
</TaxComputation>
<SpecialMentions />
</ExciseTaxesRow>
</DeclarationOfExciseTaxesRegistration>
</Body>
</EF15A>

We have the same problem with EF15 submission through web service.
SubmittingTraderIdentification is never passed even if it is completed inside the xml message.
Greek custom authorities have not an explanation for this problem.
Our customers manually upload ef15 xml file

Related

C# Web Reference - ArrayOfString not serialising

I am using Web References in C# to interface with Magento, which uses a SOAP API. The WSDL contains lots of definitions as you can imagine, but I'm having a problem with this particular one:
<complexType name="ArrayOfString">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
</restriction>
</complexContent>
</complexType>
Any propertes of a method that are an ArrayOfString are being brought back to my code as string[], which is fine, but when serialising it back to Magento it's serialising it as below
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:Magento" xmlns:types="urn:Magento/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:catalogProductCreate>
<sessionId xsi:type="xsd:string">xxxxxxxxxxxxxxxxxxxxxxx</sessionId>
<type xsi:type="xsd:string">simple</type>
<set xsi:type="xsd:string">63</set>
<sku xsi:type="xsd:string">CHRISTEST</sku>
<productData href="#id1" />
</tns:catalogProductCreate>
<tns:catalogProductCreateEntity id="id1" xsi:type="tns:catalogProductCreateEntity">
<categories href="#id2" />
<websites href="#id3" />
<name xsi:type="xsd:string">Chris Test 8</name>
<description xsi:type="xsd:string">fsd</description>
<short_description xsi:type="xsd:string">Chris Test 8</short_description>
<weight xsi:type="xsd:string">0.0000</weight>
<status xsi:type="xsd:string">1</status>
<visibility xsi:type="xsd:string">1</visibility>
<category_ids href="#id4" />
<website_ids href="#id5" />
<price xsi:type="xsd:string">0.00000</price>
<tax_class_id xsi:type="xsd:string">4</tax_class_id>
<tier_price href="#id6" />
</tns:catalogProductCreateEntity>
<soapenc:Array id="id2" soapenc:arrayType="xsd:string[0]" />
<soapenc:Array id="id3" soapenc:arrayType="xsd:string[0]" />
<soapenc:Array id="id4" soapenc:arrayType="xsd:string[1]">
<Item>35</Item>
</soapenc:Array>
<soapenc:Array id="id5" soapenc:arrayType="xsd:string[1]">
<Item>1</Item>
</soapenc:Array>
<soapenc:Array id="id6" soapenc:arrayType="tns:catalogProductTierPriceEntity[0]" />
</soap:Body>
</soap:Envelope>
And this is resulting in the arrays being ignored. I believe the reason the ArrayOfString entity isn't being added to my service model is because it has a 'restriction', but I'm going to need this to get the data back to Magento. Any ideas guys?

WCF Webservice always returning null

I am consuming a SOAP webservice from our ticket system OTRS. So the Webservice is not really under my control.
The request works just fine, but i am never getting an answer in my Code. The answer is always null. (var response = client.SessionCreate(session);)
The strange thing is, that wireshark and the webservice console of that ticket system are saying that i should receive a valid answer.
Since i am very new to this webservice stuff so i have absolutely no idea where to start in this case. So here is a description of that i did. Any suggestion is really appreciated.
First i created a normal C# project and added the WSDL file which can be found only on the GitHub site website of the OTRS project. I added it as a Service Reference and than added my C# code which looks like this.
// For Debug
System.Net.ServicePointManager.Expect100Continue = false;
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
try
{
OTRS.OTRS_Error err = new OTRS.OTRS_Error();
OTRS.GenericTicketConnector_PortTypeClient client = new OTRS.GenericTicketConnector_PortTypeClient("GenericTicketConnector_Port");
OTRS.SessionCreate session = new OTRS.SessionCreate();
session.Item = "someUserNameGoesHere";
session.ItemElementName = OTRS.ItemChoiceType8.UserLogin;
session.Password = "SomePasswordGoesHere";
var response = client.SessionCreate(session);
Console.WriteLine(response.SessionID);
Console.WriteLine(response.Error);
}
catch (Exception exep)
{
Console.WriteLine(exep.Message);
Console.WriteLine(exep.InnerException);
}
finally
{
Console.ReadLine();
}
Incoming message at serverside
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.otrs.org/TicketConnector/SessionCreate</a:Action>
<a:MessageID>urn:uuid:14750529-3de2-4618-8db4-8ac18b681c18</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://SomeServer/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector</a:To>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SessionCreate xmlns="http://www.otrs.org/TicketConnector/">
<UserLogin xmlns="">someUserName</UserLogin>
<Password xmlns="">somePassword</Password>
</SessionCreate>
</s:Body>
Outgoing message at serverside
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<SessionCreateResponse xmlns="http://www.otrs.org/TicketConnector/">
<SessionID>SomeSessionID</SessionID>
</SessionCreateResponse>
</soap:Body>
</soap:Envelope>
Wireshark HTTP/XML package going from the server to my client
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<SessionCreateResponse xmlns="http://www.otrs.org/TicketConnector/">
<SessionID>SomeSessionID</SessionID>
</SessionCreateResponse>
</soap:Body>
</soap:Envelope>
Refernce.cs
https://gist.github.com/HansVader/1ba3847d918ee15ef16703c8ada6c9bf
WSDL
https://gist.github.com/HansVader/dd849e49f4a1584397cd21b0e430b301
I currently only need the SessionnCreate and TicketUpdate function. The other operations are irrelevant at this point in time. Please let me know if you need any other informations.
Update:
Here are the traces from the trace tool like yildizm85 suggested in the comments:
I think it is also worth noting that i created the refernce.cs
by myself with the svcutil tool because i had a problem with the IsWrapped. Have a look at this question and answer:
XmlSerializer attribute not valid in Web Service using WCF
The WSDL does not define elementFormDefault:
<xsd:schema targetNamespace="http://www.otrs.org/TicketConnector/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Since unqualified is default, this causes every property to be decorated with Form=System.Xml.Schema.XmlSchemaForm.Unqualified in the generated reference file.
But, since there is a default namespace specified for each complex object, the XML serializer will not process the unqualified properties.
The solution
Change the schema element to:
<xsd:schema targetNamespace="http://www.otrs.org/TicketConnector/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
Also, for some of the properties, the order is wrong, so they need to be changed to (for example TickerCreateResponse):
<xsd:element name="TicketCreateResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="ArticleID" type="xsd:positiveInteger"/>
<xsd:element maxOccurs="1" minOccurs="1" name="TicketID" type="xsd:positiveInteger"/>
<xsd:element minOccurs="1" name="TicketNumber" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="Error" type="tns:OTRS_Error"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
After these changes, create the proxy using svcutil:
svcutil.exe /serializer:XmlSerializer GenericTicketConnectorSOAP.wsdl /o:OtrsConnector.cs /wrapped /n:*,otrs
And using the config:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="GenericTicketConnector_Binding">
<textMessageEncoding messageVersion="Soap12" writeEncoding="utf-8" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnector"
binding="customBinding" bindingConfiguration="GenericTicketConnector_Binding"
contract="otrs.GenericTicketConnector_PortType" name="GenericTicketConnector_Port" />
</client>
</system.serviceModel>
It should work after that, at least it did for me.
Hope it works for you as well!

How do you generate xsd namespace prefixes in the resulting output file?

I've gone over multiple topics and solutions that talk specifically about this issue. None have worked or I fail to understand what I am doing wrong.
I would like for the namespace prefixes to accompany the element names in the resulting xml output file.
I'm am using the XSD command with Visual Studio 2008 from the VS Command Prompt
Here's my xsd schema for Trial.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Junk"
targetNamespace="http://www.opengis.net/kml/2.2"
xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:import namespace="http://www.google.com/kml/ext/2.2" schemaLocation="TestSchema.xsd" />
<!-- Start LookType -->
<xs:complexType name="LookType">
<xs:sequence>
<xs:element ref="gx:TimeSpan" minOccurs="0" />
<xs:element name="longitude" type="xs:string" />
</xs:sequence>
</xs:complexType>
<!-- End LookType -->
<xs:element name="Te" type="LookType" />
</xs:schema>
Here's my xsd schema for TestSchema.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TestSchema"
targetNamespace="http://www.google.com/kml/ext/2.2"
xmlns="http://www.google.com/kml/ext/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="TimeSpan" type="gx:GXTimeSpanType" />
<!-- Start GXTimeSpanType -->
<xs:complexType name="GXTimeSpanType">
<xs:sequence>
<xs:element name="begin" type="xs:string" />
<xs:element name="end" type="xs:string" />
</xs:sequence>
</xs:complexType>
<!-- End GXTimeSpanType -->
</xs:schema>
I´m generating the resulting class file Trial.cs by using xsd TestSchema.xsd ./Trial.xsd /c /l:cs /n:T
In a program I assign these junk values and write them to file using XmlDocument, XmlSerializer and FileStream
T.LookType te = new T.LookType();
te.longitude = "34.444";
te.TimeSpan = new T.GXTimeSpanType();
te.TimeSpan.begin = "2010-02-26T20:22:00Z";
te.TimeSpan.end = "2010-02-26T20:23:42Z";
I've excluded the method that saves out the file using XmlDocument, XmlSerializer and FileStream as it is a little thicker then I'd like to post unless that is part of the problem.
This is what I get in the resulting file
<?xml version="1.0" encoding="utf-16"?>
<Te xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.opengis.net/kml/2.2">
<TimeSpan xmlns="http://www.google.com/kml/ext/2.2">
<begin>2010-02-26T20:22:00Z</begin>
<end>2010-02-26T20:23:42Z</end>
</TimeSpan>
<longitude>34.444</longitude>
</Te>
This is what I want in the resulting file. Notice the gx:TimeSpan element and the xmlns:gx namespace definition being added to the main Te element.
<?xml version="1.0" encoding="utf-16"?>
<Te xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2">
<gx:TimeSpan>
<begin>2010-02-26T20:22:00Z</begin>
<end>2010-02-26T20:23:42Z</end>
</gx:TimeSpan>
<longitude>34.444</longitude>
</Te>
It doesn't matter on which element the prefixes are declared on, as long as they're declared before they are used. Any code that doesn't like this is broken.
Perhaps because it doesn't matter, XML Schema has no way to influence on which element the prefixes are declared, or which prefix is used.

Use C#.Net 2010 to invoke methods on a remote web service and use its data

I'm creating a windows application on Visual Studio .Net 2010 with C#. There's a working Web service on the internet with API methods. Here's an example of one of them, they work with SOAP messages:
So you enter a username and password string on this SOAP request:
POST /anp.asmx HTTP/1.1
Host: api.anp.se
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://api.anp.se/GetOptOutList"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetOptOutList xmlns="http://api.anp.se/">
<strUsername>string</strUsername>
<strPassword>string</strPassword>
<strMailingListID>string</strMailingListID>
</GetOptOutList>
</soap:Body>
</soap:Envelope>
And the format of the SOAP response looks like this:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetOptOutListResponse xmlns="http://api.anp.se/">
<GetOptOutListResult>
<xsd:schema>schema</xsd:schema>xml</GetOptOutListResult>
</GetOptOutListResponse>
</soap:Body>
</soap:Envelope>
And when you click on the invoke button, the online service returns an XML dataset, here's a snippet of the result:
<DataSet xmlns="http://api.anp.se/">
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Report">
<xs:complexType>
<xs:sequence>
<xs:element name="SendQueueID" type="xs:int" minOccurs="0"/>
<xs:element name="SendTime" type="xs:dateTime" minOccurs="0"/>
<xs:element name="Subject" type="xs:string" minOccurs="0"/>
<xs:element name="SubscriberCount" type="xs:int" minOccurs="0"/>
<xs:element name="MailingList" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Report diffgr:id="Report1" msdata:rowOrder="0">
<SendQueueID>1235163</SendQueueID>
<SendTime>2011-06-20T12:26:54.25+02:00</SendTime>
<Subject>Tack för din bokning</Subject>
<SubscriberCount>939</SubscriberCount>
<MailingList>Tack för din bokning 2011-06-20</MailingList>
</Report>
<Report diffgr:id="Report2" msdata:rowOrder="1">
<SendQueueID>1235146</SendQueueID>
<SendTime>2011-06-20T12:15:55.62+02:00</SendTime>
<Subject>Välkommen hem</Subject>
<SubscriberCount>688</SubscriberCount>
<MailingList>Välkommen hem 2011-06-20</MailingList>
</Report>
<Report diffgr:id="Report3" msdata:rowOrder="2">
<SendQueueID>1235128</SendQueueID>
<SendTime>2011-06-20T12:08:54.277+02:00</SendTime>
<Subject>Trevlig resa</Subject>
<SubscriberCount>832</SubscriberCount>
<MailingList>Trevlig resa 2011-06-20</MailingList>
</Report>
<Report diffgr:id="Report4" msdata:rowOrder="3">
<SendQueueID>1232232</SendQueueID>
<SendTime>2011-06-17T12:07:54.767+02:00</SendTime>
<Subject>Tack för din bokning</Subject>
<SubscriberCount>398</SubscriberCount>
<MailingList>Tack för din bokning 2011-06-17</MailingList>
</Report>
If you're referring me to a tutorial, please make sure it's straight to the point and useful because I've seen lots of them that cannot help me. I need to work with the data set. How can I obtain the dataset object and how can I access the data inside it? Do I have to add service preferences to my project and what type of .Net project should it be? Thanks in advance.
Just about any type of C# project should work. You just need to right-click on the project and select "Add Service Reference". Then you can put the url into the Address textbox, give it a name, and hit ok. This should create a service proxy class containing everything you need, including all the classes returned by the service.
I haven't done this in a long time. This very basic example uses the Dilbert Web Service:
DilbertSoapClient client = new DilbertSoapClient();
string s = client.DailyDilbert(DateTime.Now);
DataTable table = new DataTable();
StringReader reader = new StringReader(s);
table.ReadXml(reader);
foreach (DataRow row in table.Rows)
{
// do something with the row
}
Of course, I don't have the webservice you are actually using, so dealing with it may vary a bit, but this is the basic model.

Contract-First WCF for Salesforce Outbound Messaging

I am looking at implementing listener application for Salesforce Outbound Messaging.
The walk through implements it using the deprecated ASMX web service. The code is generated using wsdl.exe with /serverInterface switch.
Here is the wsdl of Salesforce Outbound Messaging.
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://soap.sforce.com/2005/09/outbound"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://soap.sforce.com/2005/09/outbound"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ent="urn:enterprise.soap.sforce.com"
xmlns:ens="urn:sobject.enterprise.soap.sforce.com">
<types>
<schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:enterprise.soap.sforce.com">
<!-- Our simple ID Type -->
<simpleType name="ID">
<restriction base="xsd:string">
<length value="18"/>
<pattern value='[a-zA-Z0-9]{18}'/>
</restriction>
</simpleType>
</schema>
<schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:sobject.enterprise.soap.sforce.com">
<import namespace="urn:enterprise.soap.sforce.com" />
<!-- Base sObject (abstract) -->
<complexType name="sObject">
<sequence>
<element name="fieldsToNull" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<element name="Id" type="ent:ID" nillable="true" />
</sequence>
</complexType>
<complexType name="AggregateResult">
<complexContent>
<extension base="ens:sObject">
<sequence>
<any namespace="##targetNamespace" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="Contact">
<complexContent>
<extension base="ens:sObject">
<sequence>
<element name="Email" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="FirstName" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="LastName" nillable="true" minOccurs="0" type="xsd:string"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
<schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://soap.sforce.com/2005/09/outbound">
<import namespace="urn:enterprise.soap.sforce.com" />
<import namespace="urn:sobject.enterprise.soap.sforce.com" />
<element name="notifications">
<complexType>
<sequence>
<element name="OrganizationId" type="ent:ID" />
<element name="ActionId" type="ent:ID" />
<element name="SessionId" type="xsd:string" nillable="true" />
<element name="EnterpriseUrl" type="xsd:string" />
<element name="PartnerUrl" type="xsd:string" />
<element name="Notification" maxOccurs="100" type="tns:ContactNotification" />
</sequence>
</complexType>
</element>
<complexType name="ContactNotification">
<sequence>
<element name="Id" type="ent:ID" />
<element name="sObject" type="ens:Contact" />
</sequence>
</complexType>
<element name="notificationsResponse">
<complexType>
<sequence>
<element name="Ack" type="xsd:boolean" />
</sequence>
</complexType>
</element>
</schema>
</types>
<!-- Method Messages -->
<message name="notificationsRequest">
<part element="tns:notifications" name="request"/>
</message>
<message name="notificationsResponse">
<part element="tns:notificationsResponse" name="response"/>
</message>
<!-- PortType -->
<portType name="NotificationPort">
<operation name="notifications">
<documentation>Process a number of notifications.</documentation>
<input message="tns:notificationsRequest"/>
<output message="tns:notificationsResponse"/>
</operation>
</portType>
<!-- Binding
You need to write a service that implements this binding to receive the notifications
-->
<binding name="NotificationBinding" type="tns:NotificationPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="notifications">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<!-- Service Endpoint -->
<service name="NotificationService">
<documentation>Notification Service Implementation</documentation>
<port binding="tns:NotificationBinding" name="Notification">
<soap:address location="http://www.myserver.com/salesforceoutboundprototype/notificationport.svc"/>
</port>
</service>
</definitions>
tldr is I need to implement NotificationBinding so that Salesforce can call my webservice when an event occurs on their system.
I since have realised svcutil does not natively support Contract-First development.
As per Contract-First SOA with WCF I used WSCF.Blue to generate server-side stubs from Salesforce wsdl. Whilst the code compiles wsdl generated by my service does not have the required notifications operation.
I wonder what I am going wrong?
So I managed to do quick implementation of Salesforce wsdl using wsdl.exe and /serverInterface and it seems the wsdl generated by asmx based application is quite different from wcf based application.
This is the interface created by wsdl.exe with /serverInterface
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")]
[System.Web.Services.WebServiceBindingAttribute(Name="NotificationBinding", Namespace="http://soap.sforce.com/2005/09/outbound")]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(sObject))]
public interface INotificationBinding {
/// <remarks/>
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("notificationsResponse", Namespace="http://soap.sforce.com/2005/09/outbound")]
notificationsResponse notifications([System.Xml.Serialization.XmlElementAttribute("notifications", Namespace="http://soap.sforce.com/2005/09/outbound")] notifications notifications1);
}
This is the interface created by WSCF.Blue
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://soap.sforce.com/2005/09/outbound", ConfigurationName="INotificationPort")]
public interface INotificationPort
{
// CODEGEN: Generating message contract since the operation notifications is neither RPC nor document wrapped.
[System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(sObject))]
notificationsResponse1 notifications(notificationsRequest request);
}
They seem to be fairly similar so I don't know why wsdl generated by these application would be so different? Is it worthwhile adding wsdls (don't want to make the question any longer then it already is)?
You may not like what I suggest but I believe it will actually be the best option for you. Use ASMX. I have three OM listeners and they all work just fine under 4.0
I do not know who spreads these misfinfromations about some .NET2.0 techs but a lot of them are most certainly not obsoleted just because dev community got stricken with novelty fetish; ASMX is one of them (so is Linq2SQL, etc). WCF is simply put not yet complete, it is not fully WS compliant and that casues a lot of grief with salesforce integration (most painful being that WCF does not support soap headers where salesforce keeps session info).
For more info why asmx is NOT obsolete, see here: Does .net 4.0 still support asmx
Use svcutil to generate a client proxy and simply delete the client proxy implementation, and keep the service/data contracts. The service contract is symmetrical from a client/server point of view. I have worked on substantial contract-first projects and found this to be perfectly adequate.
Just make sure you have all of the external WSDLs available to for svcutil to resolve. I see several import statements in your WSDL text above.
BTW, WSCF.Blue is not quite up to it unfortunately as it's not been updated for a few months and is unlikely to be so in the future. Sadly, the primary developer died in a car crash last year (yes, really.)
I went through the same pain of trying to get my OBM listener working with WCF. I had originally only set up an OperationContract for the notifications method. After deploying I soon realised a Data Contract would need to be set up which I did but due to time constraints and not being entirely sure if that would be all I needed to do I simply switched to an asmx web service which worked.
I figured out an easy way to generate WCF interfaces from the Salesforce WSDL using the built in Visual Studio tools. I downloaded the WSDL from Salesforce and saved it to my desktop. In Visual Studio, go to the add service reference menu in one of your projects(doesn't matter where, you're going to delete this). For the Url, type in the path to the WSDL you downloaded locally (i.e. C:\Users\yourusername\Desktop\notification.wsdl)
This should bring load in the data for the service. Click okay to create the reference and now in the services references folder, double click on the reference you just created. This should show you the object browser with the namespace of the service reference you just created being highlighted. Double click on any of the classes inside this namespace and it will open up the related reference.cs that was generated by visual studio.
Copy all of the content inside the namespace declaration to the file of your choice with whatever namespace you decide. You can rename that interface as well if you plan to handle more than one outbound message (default should be NotificationPort). The interface will have references to the namespace you built it with but you can remove all of the namespacing in the file because all of the classes it is referring to are in the same file.
Create a new WCF service class. Delete the interface that is automatically created with the svc file and change the interface name to the one that you just copied to the new file.
By default, Visual Studio created some an async method which was throwing errors when I tried to implement it. I just deleted it from the interface and used the standard notification method.
I did this in VS2013 but it should be the same for 2010 and 2012 as well. Make sure you are using 'Add Service Reference' and not 'Add Web Reference'. Don't forget to delete the generated reference as you will not be using it.
WSCF provides a contract-first tool with VS integration.

Categories

Resources