c# - web service request call SOAP request missing empty parameters -
i'm new both web services , c# please forgive me if question simple. i've searched around cannot find answer -- @ least 1 based on keywords.
i trying call web service via c# (visual web developer 2010 express) error response. when call same web service via soapui not error. when compare soap request c# against soap request soapui c# soap request missing intentionally empty parameter <aclobjectid>
. when take empty parameter out of soapui request same error. me, answer c# send parameter though empty. tried setting null or "" no avail. there way force c# web service client send empty parameter or perhaps send parameters if not have value?
wsdl
<?xml version="1.0" encoding="utf-8"?><!-- published jax-ws ri @ http://jax-ws.dev.java.net. ri's version jax-ws ri 2.1.3-b02-. --><!-- generated jax-ws ri @ http://jax-ws.dev.java.net. ri's version jax-ws ri 2.1.3-b02-. --><definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://search.services.redacted/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetnamespace="http://search.services.redacted/" name="edrsearchservicesoapimplservice"> <types> <xsd:schema> <xsd:import namespace="http://search.services.redacted/" schemalocation="http://wwwdev.redacted:80/edrsearch?xsd=1"></xsd:import> </xsd:schema> </types> <message name="processsearch"> <part name="parameters" element="tns:processsearch"></part> </message> <message name="processsearchresponse"> <part name="parameters" element="tns:processsearchresponse"></part> </message> <message name="getattributes"> <part name="parameters" element="tns:getattributes"></part> </message> <message name="getattributesresponse"> <part name="parameters" element="tns:getattributesresponse"></part> </message> <message name="getaclusers"> <part name="parameters" element="tns:getaclusers"></part> </message> <message name="getaclusersresponse"> <part name="parameters" element="tns:getaclusersresponse"></part> </message> <porttype name="edrsearchservicesoapimpl"> <operation name="processsearch"> <input message="tns:processsearch"></input> <output message="tns:processsearchresponse"></output> </operation> <operation name="getattributes"> <input message="tns:getattributes"></input> <output message="tns:getattributesresponse"></output> </operation> <operation name="getaclusers"> <input message="tns:getaclusers"></input> <output message="tns:getaclusersresponse"></output> </operation> </porttype> <binding name="edrsearchservicesoapimplportbinding" type="tns:edrsearchservicesoapimpl"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding> <operation name="processsearch"> <soap:operation soapaction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> <operation name="getattributes"> <soap:operation soapaction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> <operation name="getaclusers"> <soap:operation soapaction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> </binding> <service name="edrsearchservicesoapimplservice"> <port name="edrsearchservicesoapimplport" binding="tns:edrsearchservicesoapimplportbinding"> <soap:address location="http://wwwdev.redacted:80/edrsearch"></soap:address> </port> </service> </definitions>
c# soap (doesn't work)
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:body xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <getaclusers xmlns="http://search.services.redacted/"> <aclusersrequest xmlns=""> <docbase>edmsdev</docbase> <aclname>my_acl</aclname> </aclusersrequest> <usercredentials xmlns=""> <username>spoonyfork</username> <password>my_password</password> <docbase>edmsdev</docbase> </usercredentials> </getaclusers> </s:body> </s:envelope>
soapui soap (works)
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sear="http://search.services.redacted/"> <soapenv:header/> <soapenv:body> <sear:getaclusers> <!--optional:--> <aclusersrequest> <docbase>edmsdev</docbase> <aclname>my_acl</aclname> <aclobjectid></aclobjectid> </aclusersrequest> <!--optional:--> <usercredentials> <username>spoonyfork</username> <!--optional:--> <password>my_password</password> <!--optional:--> <wsl4cookie></wsl4cookie> <!--optional:--> <enduserforproxyid></enduserforproxyid> <!--optional:--> <ip></ip> <!--optional:--> <docbase>edmsdev</docbase> </usercredentials> </sear:getaclusers> </soapenv:body> </soapenv:envelope>
edrsearch xsd
<?xml version="1.0" encoding="utf-8"?><!-- published jax-ws ri @ http://jax-ws.dev.java.net. ri's version jax-ws ri 2.1.3-b02-. --><xs:schema xmlns:tns="http://search.services.redacted/" xmlns:xs="http://www.w3.org/2001/xmlschema" version="1.0" targetnamespace="http://search.services.redacted/"> <xs:element name="getaclusers" type="tns:getaclusers"></xs:element> <xs:element name="getaclusersresponse" type="tns:getaclusersresponse"></xs:element> <xs:element name="getattributes" type="tns:getattributes"></xs:element> <xs:element name="getattributesresponse" type="tns:getattributesresponse"></xs:element> <xs:element name="processsearch" type="tns:processsearch"></xs:element> <xs:element name="processsearchresponse" type="tns:processsearchresponse"></xs:element> <xs:complextype name="getaclusers"> <xs:sequence> <xs:element name="aclusersrequest" type="tns:aclusersrequest" minoccurs="0"></xs:element> <xs:element name="usercredentials" type="tns:usercredentials" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="aclusersrequest"> <xs:sequence> <xs:element name="docbase" type="xs:string"></xs:element> <xs:element name="aclname" type="xs:string"></xs:element> <xs:element name="aclobjectid" type="xs:string"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="usercredentials"> <xs:sequence> <xs:element name="username" type="xs:string"></xs:element> <xs:element name="password" type="xs:string" minoccurs="0"></xs:element> <xs:element name="wsl4cookie" type="xs:string" minoccurs="0"></xs:element> <xs:element name="enduserforproxyid" type="xs:string" minoccurs="0"></xs:element> <xs:element name="ip" type="xs:string" minoccurs="0"></xs:element> <xs:element name="docbase" type="xs:string" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="getaclusersresponse"> <xs:sequence> <xs:element name="return" type="tns:aclusersresponse" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="aclusersresponse"> <xs:sequence> <xs:element name="user" type="xs:string" maxoccurs="unbounded"></xs:element> <xs:element name="largegroups" type="xs:string" maxoccurs="unbounded"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="processsearch"> <xs:sequence> <xs:element name="searchrequest" type="tns:searchrequest" minoccurs="0"></xs:element> <xs:element name="usercredentials" type="tns:usercredentials" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="searchrequest"> <xs:sequence> <xs:element name="version" type="xs:string"></xs:element> <xs:element name="docbase" type="xs:string"></xs:element> <xs:element name="searchcriteria" type="tns:logicalop" maxoccurs="unbounded"></xs:element> <xs:element name="maxnumberofdocuments" type="xs:string"></xs:element> <xs:element name="folderpaths" type="xs:string" maxoccurs="unbounded"></xs:element> <xs:element name="metadatalist" type="xs:string" maxoccurs="unbounded"></xs:element> <xs:element name="objecttype" type="xs:string"></xs:element> <xs:element name="documentlaunchsettings" type="tns:documentlaunchsettings"></xs:element> <xs:element name="documentaclsettings" type="tns:documentaclsettings"></xs:element> <xs:element name="oraclehint" type="xs:string" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="logicalop"> <xs:sequence> <xs:element name="type" type="xs:string"></xs:element> <xs:element name="name" type="xs:string"></xs:element> <xs:element name="value" type="xs:string"></xs:element> <xs:element name="logical" type="xs:string"></xs:element> <xs:element name="relational" type="xs:string"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="documentlaunchsettings"> <xs:sequence> <xs:element name="launcher" type="xs:string"></xs:element> <xs:element name="usechronicleid" type="xs:boolean"></xs:element> <xs:element name="showlink" type="xs:boolean"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="documentaclsettings"> <xs:sequence> <xs:element name="returnacl" type="xs:boolean"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="processsearchresponse"> <xs:sequence> <xs:element name="return" type="tns:searchresponse" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="searchresponse"> <xs:sequence> <xs:element name="docbase" type="xs:string" minoccurs="0"></xs:element> <xs:element name="documents" type="tns:document" nillable="true" minoccurs="0" maxoccurs="unbounded"></xs:element> <xs:element name="numberofdocuments" type="xs:string" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="document"> <xs:sequence> <xs:element name="objectid" type="xs:string"></xs:element> <xs:element name="linklocation" type="xs:string"></xs:element> <xs:element name="metadatalist" type="tns:metadataitem" maxoccurs="unbounded"></xs:element> <xs:element name="aclinfo" type="tns:aclinfo" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="metadataitem"> <xs:sequence> <xs:element name="name" type="xs:string"></xs:element> <xs:element name="value" type="xs:string"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="aclinfo"> <xs:sequence> <xs:element name="aclname" type="xs:string"></xs:element> <xs:element name="aclobjectid" type="xs:string"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="getattributes"> <xs:sequence> <xs:element name="attributesrequest" type="tns:objecttype" minoccurs="0"></xs:element> <xs:element name="usercredentials" type="tns:usercredentials" minoccurs="0"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="objecttype"> <xs:sequence> <xs:element name="docbase" type="xs:string"></xs:element> <xs:element name="objecttype" type="xs:string"></xs:element> </xs:sequence> </xs:complextype> <xs:complextype name="getattributesresponse"> <xs:sequence> <xs:element name="return" type="xs:string" minoccurs="0" maxoccurs="unbounded"></xs:element> </xs:sequence> </xs:complextype> </xs:schema>
c# code
servicereference1.usercredentials uc = new servicereference1.usercredentials(); uc.username = "spoonyfork"; uc.password = "my_password"; uc.docbase = "edmsdev"; servicereference1.aclusersrequest aurt = new servicereference1.aclusersrequest(); aurt.aclname = "my_acl"; aurt.docbase = "edmsdev"; servicereference1.edrsearchservicesoapimplclient client = new servicereference1.edrsearchservicesoapimplclient(); servicereference1.aclusersresponse aure = new servicereference1.aclusersresponse(); aure = client.getaclusers(aurt, uc);
first, can try declare aclobjectid
property serialize if null
. you'll need find definition of class aclusersrequest
, add
[system.xml.serialization.xmlelementattribute(isnullable=true)]
for property. 'll include soap request <aclobjectid xsi:nil="true" />
second, can declare property string.empty
:
edrsearchservicesoapimplclient client = new edrsearchservicesoapimplclient(); var test = client.getaclusers( new aclusersrequest() { aclname = "my_acl", docbase = "qwe", aclobjectid=string.empty },//this should trick new usercredentials() { username = "lala", password = "123", docbase = "qwe" });
that 'll include soap request <aclobjectid />
equal <aclobjectid></aclobjectid>
if neither of methods work, dealing bad web service provider , need implement self written client format message forced provider.
Comments
Post a Comment