c# - Creating my first soap request -


i'm new web services/api calls

i've been given wsdl development.

http://bogus.com/sm/7/servicecatalogapi.wsdl

i've added service reference wsdl using visual studio 2010 c# .net 4.0

i've been given username/password (basic authentication)

i'm looking guidance on how request. on right path?

i have following, i'm receiving 'cannot implicitly convert type 'string' 'sm9.servicereference1.stringtype'

protected void button1_click(object sender, eventargs e) {     try     {         servicereference1.createcartrequest createcart = new servicereference1.createcartrequest();          string result = createcart.model.instance.briefdescription = "testing sm9";          label1.text = result.tostring();     }     catch (system.exception ex)     {         label1.text = ex.message;     } } 

soap request

<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:ns="http://schemas.hp.com/sm/7" xmlns:cmn="http://schemas.hp.com/sm/7/common">   <soap:body>     <ns:createcartrequest>       <ns:model>         <ns:keys/>         <ns:instance>           <ns:briefdescription type="">brief description</ns:briefdescription>           <ns:description type="">             <ns:description type="">description 1</ns:description>             <ns:description type="">description 2</ns:description>           </ns:description>         </ns:instance>       </ns:model>     </ns:createcartrequest>   </soap:body> </soap:envelope> 

soap response

<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">   <soap-env:body>     <createcartresponse message="success" returncode="0" schemarevisiondate="2012-09-12" schemarevisionlevel="0" status="success" xmlns="http://schemas.hp.com/sm/7" xmlns:cmn="http://schemas.hp.com/sm/7/common" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://schemas.hp.com/sm/7 http://se104636.devfg.rbc.com:12700/sm/7/cart.xsd">       <model>         <keys>           <cartid type="decimal">11</cartid>         </keys>         <instance recordid="11" uniquequery="cartid=11">           <cartid type="decimal">11</cartid>           <completed type="boolean">false</completed>           <briefdescription type="string">brief description</briefdescription>           <owner type="string">soap user</owner>           <description type="array">             <description type="string">description 1</description>             <description type="string">description 2</description>           </description>           <cost type="decimal">0</cost>         </instance>       </model>       <messages>         <cmn:message>svccart record added.</cmn:message>       </messages>     </createcartresponse>   </soap-env:body> 

it looks briefdescription not of type string. try this:

string result = createcart.model.instance.briefdescription = new stringtype("testing sm9"); 

or

 string result = createcart.model.instance.briefdescription = new stringtype() { value = "testing sm9" }; 

(sorry don't know properties "stringtype" has).


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -