wsdl customization
hello there,
i'm facing troubles. client asked me customized wsdl definition comes out
of box when invoking http://mysite/myservice.asmx?wsdl
this client's requierement has changing names of tags; far i've been able
to change of them, i'm getting "ugly" errors.
basically i've been asked provide following customization:
1. namespace
format: "http://patrimonio.com.mx/" + businessobjectname (all letters in lowercase)
2. service tag
attribute: name
format: "manage" + businessobjectname + "in"
3. binding tag
attribute: name
format: "manage" + businessobjectname + "in"
4. port tag
attribute: name
format : businessobjectname
5. port type tag
attribute: name
format: businessobjectname + "in"
note: businessobjectname = weatherconversion (for sake of simplicity)
so far i've been able change first four; when try set port type name and
update type attribute binding tag, i'm getting errors.
these code snippets:
[webservice(namespace = "http://patrimonio.com.mx/weatherconversion", name = "manageweatherconversionin")]
[webservicebinding(conformsto = wsiprofiles.basicprofile1_1, name = "manageweatherconversionin")]
[toolboxitem(false)]
public class weatherconversionws : system.web.services.webservice
{
[webmethod]
[soapdocumentmethod(binding = "manageweatherconversionin")]
public string helloworld()
{
return "hello world";
}
}
public class customedwsdlreflector : soapextensionreflector
{
public string businessobjectname = "weatherconversion";
public customedwsdlreflector() { }
public override void reflectmethod() { }
public override void reflectdescription()
{
servicedescription description = reflectioncontext.servicedescription;
foreach (service service in description.services)
{
foreach (port port in service.ports)
{
port.name = this.businessobjectname;
}
}
}
}
and wsdl generated ...
although want ... guess "type" attribute equal porttype name
<wsdl:porttype name="weatherconversionin"> ,
<wsdl:binding name="manageweatherconversionin" type="tns:weatherconversionin">
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textmatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://mydomain.com/weatherconversion"
xmlns:s="http://www.w3.org/2001/xmlschema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetnamespace="http://mydomain.com/weatherconversion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementformdefault="qualified" targetnamespace="http://mydomain.com/weatherconversion">
<s:element name="helloworld">
<s:complextype />
</s:element>
<s:element name="helloworldresponse">
<s:complextype>
<s:sequence>
<s:element minoccurs="0" maxoccurs="1" name="helloworldresult" type="s:string" />
</s:sequence>
</s:complextype>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="helloworldsoapin">
<wsdl:part name="parameters" element="tns:helloworld" />
</wsdl:message>
<wsdl:message name="helloworldsoapout">
<wsdl:part name="parameters" element="tns:helloworldresponse" />
</wsdl:message>
<wsdl:porttype name="weatherconversionin">
<wsdl:operation name="helloworld">
<wsdl:input message="tns:helloworldsoapin" />
<wsdl:output message="tns:helloworldsoapout" />
</wsdl:operation>
</wsdl:porttype>
<wsdl:binding name="manageweatherconversionin" type="tns:manageweatherconversionin">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="helloworld">
<soap:operation soapaction="http://mydomain.com/weatherconversion/helloworld" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="manageweatherconversionin">
<wsdl:port name="weatherconversion" binding="tns:manageweatherconversionin">
<soap:address location="http://mydomain.com/weatherconversionws.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
with change porttype name attribute:
foreach (porttype porttype in description.porttypes)
{
porttype.name = this.businessobjectname + "in";
}
but if use wsdl.exe generate proxy class message:
error: element message named manageweatherconversionin namespace
http://www.domain/weatherconversion missing.
this when try update type attribute binding tag make equal the
name attribute of porttype tag ...
foreach (binding binding in description.bindings)
{
binding.type = new system.xml.xmlqualifiedname("tns:" + this.businessobjectname + "in");
}
and compile when try debug proyect following message:
system.argumentexception unhandled user code
message="cannot find definition tns:weatherconversionin. service description namespace missing.\r\nparameter name: name"
source="system.web.services"
paramname="name"
stacktrace:
at system.web.services.description.servicedescriptioncollection.getservicedescription(xmlqualifiedname name)
at system.web.services.description.servicedescriptioncollection.getporttype(xmlqualifiedname name)
at system.web.services.description.webservicesinteroperability.analyzebinding(binding binding, servicedescription description, servicedescriptioncollection descriptions, basicprofileviolationcollection violations)
at system.web.services.description.webservicesinteroperability.analyzedescription(servicedescriptioncollection descriptions, basicprofileviolationcollection violations)
at system.web.services.description.webservicesinteroperability.checkconformance(wsiprofiles claims, servicedescriptioncollection descriptions, basicprofileviolationcollection violations)
at asp.defaultwsdlhelpgenerator_aspx.page_load(object sender, eventargs e) in c:\windows\microsoft.net\framework\v2.0.50727\config\defaultwsdlhelpgenerator.aspx:line 1439
at system.web.util.callihelper.eventargfunctioncaller(intptr fp, object o, object t, eventargs e)
at system.web.util.callieventhandlerdelegateproxy.callback(object sender, eventargs e)
at system.web.ui.control.onload(eventargs e)
at system.web.ui.control.loadrecursive()
at system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint)
is there way fix thing ?
what doing wrong ? .. missing ?
thanks in advance
caesar
soapextensionreflector part of tools chain used soapextensions. idea extension added on service adding attribute web method. then, reflectmethod method of soapextensionreflector called, see attribute on method, , add extensibility elements wsdl. note intended adding own elements, not modifying elements created microsoft or others.
on client, importmethod method of soapextensionimporter see added elements, , use them add attributes client proxy code being generated. note how importmethod has single parameter, of type codeattributedeclarationcollection - can add attributes.
finally, attribute added (presumably soapextensionattribute) cause soapextension loaded on client.
result add attribute [mycompressionattribute(true)] on server, , have [mycompressionattribute(true)] added client-side proxy classes, mycompressionextension on server talk mycompressionextension on client.
btw, did read using soapextensionreflector modify existing wsdl elements?
john saunders
wcf is web services. not 2 separate things.
use wcf new web service development, instead of old asmx or obsolete wse
use file->new project create web service projects
Archived Forums A-B > ASMX Web Services and XML Serialization
Comments
Post a Comment