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?
Related
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
I was unable to execute a Soap Exhange request to update contacts:PersonalNotes .
I have not found documentation on msdn: https://msdn.microsoft.com/en-us/library/office/ee693002(v=exchg.80).aspx
this is my soap code:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2016" />
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="Eastern Standard Time" />
</t:TimeZoneContext>
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly"
ConflictResolution="AlwaysOverwrite">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId
Id="AAMkAD...QAAAz9hI5AAA=" ChangeKey="EQAAAB...QAAAz9rdN" />
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI="contacts:Notes" />
<t:Contact>
<t:Notes>TEST N</t:Notes>
</t:Contact>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
</soap:Envelope>
this the error displayed:
What is the soap code to write to edit the Contact PersonalNotes ?
The Notes field in a Contact is the Body Property of a Message so to update you need to update the body eg
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
<m:ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkADczN=" ChangeKey="EQAAABYAAAB1EEf9R" />
<t:Updates>
<t:SetItemField>
<t:FieldURI FieldURI="item:Body" />
<t:Contact>
<t:Body BodyType="Text">test text</t:Body>
</t:Contact>
</t:SetItemField>
</t:Updates>
</t:ItemChange>
</m:ItemChanges>
</m:UpdateItem>
</soap:Body>
</soap:Envelope>
I've been trying to setup the custom metrics inside NewRelic for MassTransit similar to how NServiceBus works with NewRelic. It seems that this is pretty easy to achieve using the NewRelic .Net Custom Transactions documentation.
So far from checking out the MassTransit code on GitHub I've manage to put together a simple instrumentation file for MassTransit but this only contains Message Sends, but I really want message received as well but i cant seem to find the first interception which is not tied to a transport implementation.
<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
<instrumentation>
<tracerFactory metricName="MassTransit/Send">
<match assemblyName="MassTransit" className="MassTransit.Transports.SendEndpoint">
<exactMethodMatcher methodName="Send" parameters="!!0,System.Threading.CancellationToken" />
<exactMethodMatcher methodName="Send" parameters="!!0,MassTransit.Pipeline.IPipe`1[MassTransit.SendContext`1[!!0]],System.Threading.CancellationToken" />
</match>
</tracerFactory>
</instrumentation>
</extension>
The example of the NServiceBus instrumentation file that I'm trying to create the equivalent MassTransit one is below:
<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
<instrumentation>
<tracerFactory>
<match assemblyName="NServiceBus.Core" className="NServiceBus.InvokeHandlersBehavior">
<exactMethodMatcher methodName="Invoke" parameters="NServiceBus.Pipeline.Contexts.IncomingContext,System.Action" />
</match>
</tracerFactory>
<tracerFactory>
<match assemblyName="NServiceBus.Core" className="NServiceBus.Unicast.UnicastBus">
<exactMethodMatcher methodName="SendMessage" parameters="NServiceBus.Unicast.SendOptions,NServiceBus.Unicast.Messages.LogicalMessage" />
</match>
</tracerFactory>
</instrumentation>
</extension>
UPDATE
As suggested by Chris Patterson I've updated to the new package so there is a method I can hook on to within the ReceivePipe.
I've tried to then instrument this method but with no success, i can how ever see the that its possible to instrument within the logs when turning on the ALL logging:
[Trace] 2015-10-19 09:08:45 Possibly instrumenting: (Module: D:\Liberis\Services\Liberis.Salesforce.Service\MassTransit.dll, AppDomain: Liberis.Salesforce.Service.exe)[MassTransit]MassTransit.Pipeline.Pipes.ReceivePipe.MassTransit.Pipeline.IPipe<MassTransit.ReceiveContext>.Send(MassTransit.ReceiveContext)
I've also tried updating the the configuration to the following to match the above but still had no success:
<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
<instrumentation>
<tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" metricName="MassTransit/Receive">
<match assemblyName="MassTransit" className="MassTransit.Pipeline.Pipes.ReceivePipe.MassTransit.Pipeline.IPipe<MassTransit.ReceiveContext>">
<exactMethodMatcher methodName="Send" parameters="MassTransit.ReceiveContext" />
</match>
</tracerFactory>
</instrumentation>
</extension>
I've also tried to use the nrconfig tool but that only outputs the following for the ReceivePipe class:
<match assemblyName="MassTransit" className="MassTransit.Pipeline.Pipes.ReceivePipe">
<exactMethodMatcher methodName=".ctor" parameters="MassTransit.Pipeline.IPipe`1<MassTransit.ReceiveContext>,MassTransit.Pipeline.IConsumePipe" />
</match>
I have a feeling that I need to instrument it differently due to the class implicitly implementing the IPipe<ReceiveContext> interface?
You should be able to hook the ReceivePipe.Send method in a similar fashion.
https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit/Pipeline/Pipes/ReceivePipe.cs#L30
<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
<instrumentation>
<tracerFactory metricName="MassTransit/Receive">
<match assemblyName="MassTransit" className="MassTransit.Pipeline.Pipe.ReceivePipe">
<exactMethodMatcher methodName="Send" parameters="ReceiveContext" />
</match>
</tracerFactory>
</instrumentation>
</extension>
At least, that's my guess on the XML syntax, but the method is sound.
With some help from #Chris Patterson I've managed to figure it out, lot more effort than I thought it should of been.
Below is the configuration xml that is required:
<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="urn:newrelic-extension">
<instrumentation>
<tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" metricName="MassTransit/Send">
<match assemblyName="MassTransit" className="MassTransit.Transports.SendEndpoint">
<exactMethodMatcher methodName="Send" parameters="!!0,System.Threading.CancellationToken" />
<exactMethodMatcher methodName="Send" parameters="!!0,MassTransit.Pipeline.IPipe`1[MassTransit.SendContext`1[!!0]],System.Threading.CancellationToken" />
</match>
</tracerFactory>
<tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" metricName="MassTransit/Receive">
<match assemblyName="MassTransit" className="MassTransit.Pipeline.Pipes.ReceivePipe">
<exactMethodMatcher methodName="MassTransit.Pipeline.IPipe<MassTransit.ReceiveContext>.Send" parameters="MassTransit.ReceiveContext" />
</match>
</tracerFactory>
</instrumentation>
</extension>
Seems like the method signature totally changes due to implicitly implementing the IPipe interface.
I've also added this to a github repository - https://github.com/LiberisLabs/NewRelic.Agent.CustomTransactions
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.
In my XSD, I have something similar to this:
<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:jump="testThingy" elementFormDefault="qualified" targetNamespace="testThingy" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="command" type="jump:commandType" />
<complexType name="loginType">
<sequence>
<element name="userName" />
</sequence>
</complexType>
<complexType name="commandType">
<sequence>
<choice>
<element name="login" type="jump:loginType" />
<element name="logout" />
</choice>
<!-- There are other elements here but they are IRRELEVANT to the question -->
</sequence>
</complexType>
</schema>
So, using an XSD to C# tool (xsd.exe or Xsd2Code), this generates 2 classes (commandType and loginType). But, if I wanted dto submit a logout command, the XML needs to look like this:
<command>
<logout />
</command>
But, I haven't got - whatever the equivalent of a - logoutType. In the generated class, if I wanted to use logout, then commandType is expecting an "XmlElement".
Assuming the XSD to C# tools can't generate this class for me, how do you write a class that basically comes down to just serializing to and is of type XmlElement so it fits with the commandType?
(note: I have no control over the XSD's, otherwise I would have changed it to include a new complexType)
Based on the schema that has now been posted, it's clear why you have an XmlElement for logout. What do you think the type of the logout element is? It's xs:anyType. It could be anything at all. The only .NET type that matches that is XmlElement, unless you prefer object.
What did you want instead of XmlElement?