Consuming
Web Services in AX2012
Consuming a web
service is always very exciting in any technology. I wanted to explore the same
in AX 2012. You can download the official document regarding same using the
below link:
I tried to consume the web service mentioned in the
downloaded documents and made some modifications as well to suit my
requirements and it worked pretty well. But it was all like working as per the
document and being happy on something which was already accomplished. I wanted
to consume another web service. So, I searched the internet a bit and found out
a web service to check the weather conditions of a city and here are the steps
to get this done:
1. Create a new project:
3. Add the project to the AOT:
4. Set the deployment properties:
5. Restart the Microsoft Dynamics AX client. This is
an important step.
6. Write a job in X++ in AX 2012
to access the web service and output the result set:
Below is the output of the
job:
7. Go to AX 2012 and verify the
changes in service reference
Thanks for this post, it has been very useful for me.
ReplyDeleteHi Mukesh,
ReplyDeleteIts a nice one, i was trying the same to consume webservices works and i have created the VS2012 project all the steps until creation of the Job.
When i am initialising the webservice iam not getting compiled that and says varialble "WeatherConditions" not declared. Could you please suggest me if something i am missing.
Currently i am working on webservice to expose to outside of AX and wanted to test it using SOAP tool, t would be great if you can share points which are mandatary.
Thanks in Adv.
Regards..Satish
While adding Service Reference, what namespace you've provided?
DeleteIt should be "WeatherConditions" while adding, see above screenshot in step 2.
Hi Mukesh,
DeleteThanks for the spontaneous reply.
I have given the samename but still not recognised.
I need one more help i need i have activated a webservice for Products(standard - EcoResProductService) and trying to test it using SOAP tool, but i am getting many errors like "Invalid schema and value cannot be null".
Any suggestions please.
Thanks in Advance.
Regards
Hi, U can check the schema file (XSD) for the service. Fields which are declared as "minOccurs = 1" must be passed. Else during XML validation it will get failed.
DeleteU can check same in Inbound port > Data policies > View schema.
Hi Mukesh,
ReplyDeleteI am getting the following error.
"Assembly containing type Weather.WeatherConditionsServiceReference.GlobalWeatherSoapClient is not referenced."
Thanks.
Hi,
DeleteRefer the names u provided for .Net project. The above statement must be like
<>.<>.<>
Everytime u will put a dot between words, u will get further related methods in lookup. Just follow same.
Happy DAXing :)
Hi,
ReplyDeleteRefer the names u provided for .Net project. The above statement must be like
"ProjectNameInAOT"."Namespace"."GlobalWeatherSoapClient"
Everytime u will put a dot between words, u will get further related methods in lookup. Just follow same.
Happy DAXing :)
Hi Mukhesh...
ReplyDeleteNeed some suggestion..
I need a create a service reference which needs to import the data from iphone application. An iphone application has been created of type like pos terminal , i need to take data from iphone application and store it in Ax data base and vice versa....
Your reply is highly appreciated here...
Thank you,
Kumar.
U can create a Web service in IPhone app by using link below:
Deletehttp://blogs.oreilly.com/iphone/2008/09/creating-an-iphone-based-web-s.html
Once web service is created and hosted, u can consume same as mentioned in the above article.
Hi ,
ReplyDeleteI am getting the following error.
"XmlNode object not initialized."
Hi, Check your location, I hope u wud not be getting any string in weatherInformation object.
Deletehi,
ReplyDeletefirstly thanks for your good post.
but i have a problem i want to add Web Reference to VS then i want to use this refences in AX. adding web reference and deploy to aot is easy but i can't use web reference with X++. do u know something about using added web reference ?
Thanks
Hi Mukesh, I done all the above steps, geeting error when AX job calling getweather method
ReplyDeleteSystem.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (407) Proxy Authentication Required