I am trying to use a public web service from a web site.
For example, there's a published web service such as http://www.webservicex.net/uszip.asmx --> http://www.webservicex.net/uszip.asmx?op=GetInfoByZIP
It has one textbox for zip code entry for input parameter for the web service. After entering a value, clicking the "Invoke" button returns xml data such as the following.
<NewDataSet>
<Table>
<CITY>Fairfax</CITY>
<STATE>VA</STATE>
<ZIP>22030</ZIP>
<AREA_CODE>703</AREA_CODE>
<TIME_ZONE>E</TIME_ZONE>
</Table>
</NewDataSet>
However, the WSDL for this service doesn't have the structure of the response data - basically no meaningful type or format specified.
<s:element name="GetInfoByZIPResponse">
<s:complexType>
<s :s equence>
<s:element minOccurs="0" maxOccurs="1" name="GetInfoByZIPResult">
<s:complexType mixed="true">
<s :s equence>
<s:any/>
</s :s equence>
</s:complexType>
</s:element>
</s :s equence>
</s:complexType>
</s:element>
So, when I use a textarea element in the partial page and set GetInfoByZIPResult as the data binding, the result in the textarea is concatenation of all text value, such as "FairfaxVA22030703E".
In this case, is there a way to parse the web service response into some structured fashion so that each field is assigned to separate textbox?
It would be appreciated if you can provide detailed instruction here since MVC WebMaker documentation is not helpful at all.
Thank you,
- Steven.
For example, there's a published web service such as http://www.webservicex.net/uszip.asmx --> http://www.webservicex.net/uszip.asmx?op=GetInfoByZIP
It has one textbox for zip code entry for input parameter for the web service. After entering a value, clicking the "Invoke" button returns xml data such as the following.
<NewDataSet>
<Table>
<CITY>Fairfax</CITY>
<STATE>VA</STATE>
<ZIP>22030</ZIP>
<AREA_CODE>703</AREA_CODE>
<TIME_ZONE>E</TIME_ZONE>
</Table>
</NewDataSet>
However, the WSDL for this service doesn't have the structure of the response data - basically no meaningful type or format specified.
<s:element name="GetInfoByZIPResponse">
<s:complexType>
<s :s equence>
<s:element minOccurs="0" maxOccurs="1" name="GetInfoByZIPResult">
<s:complexType mixed="true">
<s :s equence>
<s:any/>
</s :s equence>
</s:complexType>
</s:element>
</s :s equence>
</s:complexType>
</s:element>
So, when I use a textarea element in the partial page and set GetInfoByZIPResult as the data binding, the result in the textarea is concatenation of all text value, such as "FairfaxVA22030703E".
In this case, is there a way to parse the web service response into some structured fashion so that each field is assigned to separate textbox?
It would be appreciated if you can provide detailed instruction here since MVC WebMaker documentation is not helpful at all.
Thank you,
- Steven.
RE: Parsing web service response - generic type
When you use a WSDL service definition to design your pages, WebMaker uses the information within it to help you quickly add relevant controls to the page that will be bound to the correct data. If the WSDL does not specify what data structure will be returned however it is not able to do this.
In this scenario you will instead need to add the fields you require from the design palette and then manually configure the bindings for them.
When you go to the Data Bindings tab, you will see the example data structure to bind to displayed on the right hand side. In your example this should contain the GetInfoByZIPResult element, but without any content. This document is just used to help with the bindings, so you can edit it as needed to match the required structure. You can use the 'edit' buttons at the top of the document tree to open the file up either within the browser, or an external editor.
If you know the exact structure of data returned you can manually edit the XML, but it is often easier to run the application and then use the actual data returned. After running the application, open up the logs in the Dashboard, and find the outgoing 'Agent Message' entry for the Controller that calls your page. (This is the information that will be used to render the page display.)
Use the 'Copy XML' option for this log entry, and then paste the contents into the example binding document used within FormMaker.
Now that the binding document has the correct data structure you can refresh the tree display using the link in the top right. You can now drag the relevant data entry from the tree into the Field Value binding for each of the controls you have added to the page.
If you generate and deploy the project, it should now show the correct data in each field when you run it.
I hope this helps.
Let me know if you have any more questions.
Regards,
Gerard
RE: Parsing web service response - generic type
It worked. Thank you very much.
- Steven