By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,494 Members | 1,502 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,494 IT Pros & Developers. It's quick & easy.

Separate WSDL File

P: n/a
Hi,
If anyone could help with this, I would greatly appreciate it!

I've created my own WSDL file and referenced an XSD file too. I've generated
a service side interface using wsdl /server, and created an ASMX file from
this. I've then set the Binding for the class and methods and set the
Location to my WSDL file. If I put the wsdl:service element in the WSDL file
that points to my endpoint, I can go to Add Web Reference and my methods show
up, add the reference, and all is ok.

However, what I want to do is to be able to browse to the ASMX file and do
page?WSDL to use my binding, but for Visual Studio to add the service
endpoint. So, I added a Location attribute and binding to the class and
binding to the method, but when I Add Web Reference on the asmx file, I get
no methods dispalyed (I get the error that no ports or methods are available)
and no methods added to my project. The WSDL that Visual Studio creates has
imported my WSDL file without problems, and as I said, if I use the same one
but add my own endpoint in and browse to that to add a web reference, it
works. Is there any reason why I can't create my own XSD and WSDL, set the
Location attribute to my WSDL in my code and for it to work as I expect?

This is my WSDL where I define my own service, which works:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://test.com/TestService"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://test.com/TestService" name="GetCustomerService"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<types>
<xsd:schema>
<xsd:import
schemaLocation="http://localhost/TestService/TestService.xsd"
namespace="http://test.com/TestService" />
</xsd:schema>
</types>
<message name="getCustomerIn">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<part name="messagePart" element="tns:TestRequest" />
</message>
<message name="getCustomerOut">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<part name="messagePart" element="tns:TestResponse" />
</message>
<portType name="GetCustomerServiceInterface">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<operation name="GetCustomer">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<input message="tns:getCustomerIn" />
<output message="tns:getCustomerOut" />
</operation>
</portType>
<binding name="CustomerInterface" type="tns:GetCustomerServiceInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<operation name="GetCustomer">
<soap:operation soapAction="http://test.com/TestService:GetCustomer"
style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="CustomerService">
<port name="CustomerInterface" binding="tns:CustomerInterface">
<soap:address location="http://localhost/TestService/TestService.asmx"/>
</port>
</service>
</definitions>

This is the one VS produces:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:i0="http://test.com/TestService"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://test.com/TestService"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:import namespace="http://test.com/TestService"
location="http://localhost/TestService/GetCustomerService.wsdl" />
<wsdl:types />
<wsdl:service name="CustomerService">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<wsdl:port name="CustomerInterface" binding="i0:CustomerInterface">
<soap:address location="http://localhost/TestService/TestService.asmx"
/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

This looks ok to me. The code looks like this:
namespace Test.TestService
{
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
/// <remarks/>

[System.Web.Services.WebServiceBindingAttribute(Nam e="CustomerInterface",
Namespace="http://test.com/TestService",Location="http://localhost/TestService/GetCustomerService.wsdl")]

[System.Web.Services.WebServiceAttribute(Namespace= "http://test.com/TestService")]
public class CustomerService
{

/// <remarks/>
[System.Web.Services.WebMethodAttribute()]

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://test.com/TestService:GetCustomer",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare,Binding="CustomerInterface")]
[return:
System.Xml.Serialization.XmlElementAttribute("Test Response",
Namespace="http://test.com/TestService")]
public TestResponse
GetCustomer([System.Xml.Serialization.XmlElementAttribute(Names pace="http://test.com/TestService")] TestRequest TestRequest)
{
return null;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://test.com/TestService")]
public class TestRequest
{

/// <remarks/>
public string id;
}

/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://test.com/TestService")]
public class TestResponse
{

/// <remarks/>
public string Name;

/// <remarks/>
public string Age;

/// <remarks/>
public string dob;
}
}

Thanks for any help,
Dave

Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.