How to setup custom api for Magento with SOAP V2? - c#

I am on Magento 1.4.1.1 and I am trying to setup a custom function in the API using SOAP v2. I have it working for SOAP v1 but I need v2 so that C# can use it. For v2 the function shows up in the WSDL but alwasy returns this error: Procedure 'testFoo' not present.
Here are my files:
/app/etc/modules/ABT_Test.xml
<?xml version="1.0"?>
<config>
<modules>
<ABT_Test>
<active>true</active>
<codePool>local</codePool>
</ABT_Test>
</modules>
</config>
/app/code/local/ABT/Test/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<ABT_Test>
<active>true</active>
<codePool>local</codePool>
<version>1.0</version>
</ABT_Test>
</modules>
<global>
<models>
<test>
<class>ABT_Test_Model</class>
</test>
</models>
</global>
</config>
/app/code/local/ABT/Test/etc/api.xml
<?xml version="1.0"?>
<config>
<api>
<resources>
<test>
<model>test/api</model>
<title>ABT Test Api</title>
<methods>
<foo translate="title" module="test">
<title>Foo Test</title>
<method>foo</method>
<acl>test/foo</acl>
</foo>
</methods>
</test>
</resources>
<v2>
<resources_function_prefix>
<test>test</test>
</resources_function_prefix>
</v2>
</api>
</config>
/app/code/local/ABT/Test/etc/wsdl.xml
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:typens="urn:{{var wsdl.name}}" 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="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
</schema>
</types>
<message name="testFooRequest">
<part name="sessionId" type="xsd:string" />
</message>
<message name="testFooResponse">
<part name="result" type="typens:boolean" />
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="testFoo">
<documentation>Test Foo</documentation>
<input message="typens:testFooRequest" />
<output message="typens:testFooResponse" />
</operation>
</portType>
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="testFoo">
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
<input>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
</definitions>
/app/code/local/ABT/Test/Model/API.php
<?php
class ABT_Test_Model_Api extends Mage_Api_Model_Resource_Abstract
{
public function foo()
{
return true;
}
}
?>
/app/code/local/ABT/Test/Model/API/V2.php
<?php
class ABT_Test_Model_Api_V2 extends ABT_Test_Model_Api
{
}
?>
And here is the code I use to test the API:
<?php
$mageUser = '########';
$mageApiKey = '########';
//SOAP V1
echo "SOAP V1 <br />";
$mageUrl = 'http://www.########.com/api/soap/?wsdl';
$soap = new SoapClient($mageUrl, array('cache_wsdl' => 0));
try {
$sessionID = $soap->login($mageUser, $mageApiKey);
var_dump($soap->call($sessionID, 'test.foo', array()));
} catch (Exception $e) {
echo 'Exception: ' . $e->getMessage() . '<br />';
}
//SOAP V2
echo "SOAP V2 <br />";
$mageUrl2 = 'http://www.########.com/api/v2_soap/?wsdl';
$soap2 = new SoapClient($mageUrl2, array('cache_wsdl' => 0));
try {
$sessionID2 = $soap2->login($mageUser, $mageApiKey);
var_dump($soap2->testFoo($sessionID2));
} catch (Exception $e) {
echo 'Exception: ' . $e->getMessage() . '<br />';
}
?>
I obscured the username, password and url. The function shows up in the v2 WSDL and the php code recognizes that it is in the WSDL but I still get the error: Procedure 'testFoo' not present.
So what am I missing?
EDIT:
I did what Zyava suggested and it got my example working. I then copied the folder and did an exact (case sensitive) find and replace to use a meaningful Module name and function name. I was careful to pick names that I didn't think would be reserve words. On the new module the call on the v1 WSDL works fine but the v2 gives the same "Procedure 'xxx' not present" message. I then went and renamed the method on the test from 'Foo' to 'Fooz' and I got this message: "Resource path is not callable." I find it interesting that I get a different message. This leads me to believe there is some cache/configuration/something that is causing the problem. Any ideas?

At first I should warn you that Magento doesn't support SOAP v2 format for now, api/v2_soap/?wsdl is just second version of soap api.
1.
<models>
<test>
<class>ABT_Test_Model</class>
</test>
</models>
Because you are writing module which isn't core, you should write <abt_test>
2.<model>test/api</model>. Should be <model>abt_test/api</model> in your case.
3.<acl>test/foo</acl>.
Does this acl section exist in your adminhtml.xml?

bygrace,
your code is so perfect!
add
....
<resources_alias>
<test>test</test>
</resources_alias>
.....
same level with
<resources> and <v2>
on Api.xml
and it'll be working good.

I has having the same issue and i tried clearing the tmp file as i had hosted it using xampp it didnt work i was getting Procedure ххх not present exception, I had to disable the cache management in the admin page of the server.
How to disable Cache in Admin page
In the admin page under the system there is a section called cache management disable everything during the development phase or else any change you do wont be reflected in the wsdl.

Related

How can I find the parameters of a wsdl service in 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

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!

Eliminating tempuri from a WCF Web Service which has FaultException

Background:
I've recently added internal authentication of user requests to a web service with a custom FaultException being thrown in the event of a failed authentication.
The FaultException custom type has been marked up:
[DataContract(Namespace = ConstantConfig.ServiceNamespace, Name = "AuthenticationError")]
public class AuthenticationError
The Service Interface methods have been marked up:
[OperationContract]
[FaultContract(typeof(AuthenticationError), Namespace = ConstantConfig.ServiceNamespace)]
ClientReport GetClientReport(DateTime from, DateTime to);
The interface itself has been marked up:
[ServiceContract(Namespace = ConstantConfig.ServiceNamespace)]
public interface IClientReportService
The implementation of the interface has been marked up:
[ServiceBehavior(Namespace = ConstantConfig.ServiceNamespace)]
public class ClientReportService : IClientReportService
The web.config and the app.config are all pointing at the copy/pasted service namespace.
And yet, despite all of this, I am still getting a tempuri.wsdl getting generated. Here is a reprsentative excerpt from the wsdl:
Main:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://webservice.company.com/ClientReportService" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://tempuri.org/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ClientReportService" targetNamespace="http://webservice.company.com/ClientReportService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:import namespace="http://tempuri.org/" location="http://localhost:4319/ClientReportService.svc?wsdl=wsdl0" />
<wsdl:types>
<xsd:schema targetNamespace="http://webservice.company.com/ClientReportService/Imports">
<xsd:import schemaLocation="http://localhost:4319/ClientReportService.svc?xsd=xsd0" namespace="http://webservice.company.com/ClientReportService" />
<xsd:import schemaLocation="http://localhost:4319/ClientReportService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
Tempuri:
<wsdl:operation name="GetClientReport">
<soap:operation soapAction="http://webservice.company.com/ClientReportService/IClientReportService/GetClientReport" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="AuthenticationErrorFault">
<soap:fault use="literal" name="AuthenticationErrorFault" namespace="" />
</wsdl:fault>
</wsdl:operation>
I'm guessing there is something that I have not marked up or marked up incorrectly, but am at a loss to find it.
Any suggestions?
try this
<endpoint address=""
binding="basicHttpBinding"
bindingNamespace="http://my.namespace.com"
contract=""/>
</service>
As it turns out the error was entirely mine.
In the web config the service name did not match the service name on the actual service.
Actual service (inside the markup for the .svc file):
Service="Company.Client.Framework.ReportService.ClientReportService"
Broken Web Config
<service name="Company.Client.ReportService.ReportService">
Corrected Web Config:
<service name="Company.Client.ReportService.ClientReportService">
After I corrected this and regenerated the WSDL, tempuri vanished.

How to get the list of scheduled tasks using c#?

I need to get the list of scheduled tasks that are present in the local computer.
How can I achieve that using c# for Windows XP?
1 alternative...:
1) you can read from the folder where task are saved ( Ive just tested it - win7)
c:\Windows\System32\Tasks\
this is simple xml file like this :
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2012-04-05T13:28:54.2106589</Date>
<Author>DAVIDDOM\RoyiN</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2012-04-05T13:28:43.2046589</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<RunLevel>LeastPrivilege</RunLevel>
<UserId>DAVIDDOM\RoyiN</UserId>
<LogonType>InteractiveToken</LogonType>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<Duration>PT10M</Duration>
<WaitTimeout>PT1H</WaitTimeout>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Windows\system32\charmap.exe</Command>
</Exec>
</Actions>
</Task>

Categories

Resources