---
title: "2.WSDL以及xsd编写遇到的几多困惑"
author: "冰之晴天小猪"
date: "2013-06-14T16:27:59Z"
tags: []
categories: ["编程语言"]
slug: "2-wsdl-xsd"
draft: false
lastmod: "2013-06-14T16:29:25Z"
id: 1886839
url: "https://binlee1990.iteye.com/blog/1886839"
---

WSDL：

1\. 如下两图。其实两者所实现的方法是一样的。

    区别：上图WSDL2Java会生成4个Service接口，每个接口拥有一个方法。下图只会生成一个接口，这个接口拥有4个方法。

![](http://dl2.iteye.com/upload/attachment/0085/7602/4bd71493-c59a-3ae9-b16c-c0e0ccb88b65.jpg)  
   
![](http://dl2.iteye.com/upload/attachment/0085/7608/5f63a76c-2b68-3584-8cfd-1e78c7a3dcdf.jpg)

 

Namespace：

背景：phase1拥有一个namespace叫做CustomerService，phase2客户想改成CardService，但是phase2依然访问phase1的wsdl，这样就要求，客户发送soap请求到server，server能够识别不同的namespace并返回响应消息。

困难：因为@Webservice加在interface上，只能定义一个namespace，所以发送第二个namespace时server会识别不了。不知道如何在一个接口的情况下支持两个namespace。

```
@WebService(targetNamespace = "urn:CustomerService", name = "IstPortType")
public interface IstPortType extends java.rmi.Remote {
	@WebMethod(operationName = "getCustomerByATMPin")
	@WebResult(name = "CustATMPinAuthInqOut")
	public CustATMPinAuthInqOut getCustomerByATMPin(
			@WebParam(name = "CustATMPinAuthInqInp") CustATMPinAuthInqInp getCustomerByATMPinPara)
			throws java.rmi.RemoteException;
    @WebMethod(operationName = "getCustCardInfoByCIFNo")
	@WebResult(name = "CustCardInfoInqOut")
	public CustCardInfoInqOut getCustCardInfoByCIFNo(
			@WebParam(name = "CustCardInfoInqInp") CustCardInfoInqInp getCustCardInfoByCIFNoPara)
			throws java.rmi.RemoteException;
    @WebMethod(operationName = "updateCustCardLimit")
	@WebResult(name = "CardLimitChangeOut")
	public CardLimitChangeOut updateCustCardLimit(
			@WebParam(name = "CardLimitChangeInp") CardLimitChangeInp updateCustCardLimitPara)
			throws java.rmi.RemoteException;
    @WebMethod(operationName = "updateCustCardStatus")
	@WebResult(name = "CardStatusChangeOut")
	public CardStatusChangeOut updateCustCardStatus(
			@WebParam(name = "CardStatusChangeInp") CardStatusChangeInp updateCustCardStatusPara)
			throws java.rmi.RemoteException;
    }
```