Undefined port type:{http://chillyc.info/api}Name.

来源:http://www.cnblogs.com/liqun-12345/archive/2016/06/02/5551961.html
-Advertisement-
Play Games

來自http://blog.csdn.net/cctt_1/article/details/8639903 介面代碼: package myws; import javax.jws.WebParam; import javax.jws.WebService; /** * * @author 帳前卒 ...


來自http://blog.csdn.net/cctt_1/article/details/8639903

介面代碼:

package myws;  
  
import javax.jws.WebParam;  
import javax.jws.WebService;  
  
/** 
 * 
 * @author 帳前卒 
 * 
 */  
@WebService(targetNamespace = "http://chillyc.info/api", name="HELLO")  
public interface WebServiceAPI {  
    String hello(@WebParam(name="name")String name);  
  
}  
View Code 這裡要註意的是 那個hello函數,必須與webService發佈的函數名相一致(要看wdsl文件中的名字。) 另外WebParam中的name也需要和發佈函數中的參數名字一致。 這裡WebService中傳入了兩個值。其中name就是剛纔WebService中的name. 其實就是wsdl中的portType. 如果這裡寫錯了。就會有Undefined port type:{http://chillyc.info/api}Name. 這個錯誤。所以要小心。
package myws;  
  
import java.io.IOException;  
import javax.jws.WebMethod;  
import javax.jws.WebParam;  
import javax.jws.WebResult;  
import javax.jws.WebService;  
import javax.xml.bind.annotation.XmlAccessType;  
import javax.xml.bind.annotation.XmlAccessorType;  
import javax.xml.bind.annotation.XmlRootElement;  
import javax.xml.ws.Endpoint;  
  
/** 
 * 
 * @author 帳前卒 
 * 
 */  
@WebService(  
        name="HELLO",  
        targetNamespace="http://chillyc.info/api",   
        serviceName="API",   
        portName="PortName")  
public class WebServiceHolder {  
    @WebMethod  
    @WebResult(name="return")  
    public String hello(@WebParam(name="name")String name) {  
        return "hello" + name;  
    }  
      
    public static void main(String[] args) throws IOException {  
        Endpoint.publish("http://localhost:80/fake/ws", new WebServiceHolder());  
        System.in.read();  
    }  
}  
View Code

 

調用介面代碼:

package myws;  
  
import java.net.MalformedURLException;  
import java.net.URL;  
  
import javax.xml.namespace.QName;  
import javax.xml.ws.Service;  
  
/** 
 * 
 * @author 帳前卒 
 * 
 */  
public class Client {  
    public static void main(String[] args) throws MalformedURLException {  
        WebServiceAPI api = Service.create(  
                new URL("http://localhost:80/fake/ws?wsdl"),  
                new QName("http://chillyc.info/api", "API"))  
                .getPort(WebServiceAPI.class);  
        System.out.println(api.hello("sss"));  
    }  
}  
View Code

 

wsdl內容:

This XML file does not appear to have any style information associated with it. The document tree is shown below.  
<!-- 
 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.  
-->  
<!-- 
 Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.  
-->  
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://chillyc.info/api" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://chillyc.info/api" name="API">  
<types>  
<xsd:schema>  
<xsd:import namespace="http://chillyc.info/api" schemaLocation="http://localhost/fake/ws?xsd=1"/>  
</xsd:schema>  
</types>  
<message name="hello">  
<part name="parameters" element="tns:hello"/>  
</message>  
<message name="helloResponse">  
<part name="parameters" element="tns:helloResponse"/>  
</message>  
<message name="getReturnInfo">  
<part name="parameters" element="tns:getReturnInfo"/>  
</message>  
<message name="getReturnInfoResponse">  
<part name="parameters" element="tns:getReturnInfoResponse"/>  
</message>  
<portType name="HELLO">  
<operation name="hello">  
<input message="tns:hello"/>  
<output message="tns:helloResponse"/>  
</operation>  
<operation name="getReturnInfo">  
<input message="tns:getReturnInfo"/>  
<output message="tns:getReturnInfoResponse"/>  
</operation>  
</portType>  
<binding name="PortNameBinding" type="tns:HELLO">  
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>  
<operation name="hello">  
<soap:operation soapAction=""/>  
<input>  
<soap:body use="literal"/>  
</input>  
<output>  
<soap:body use="literal"/>  
</output>  
</operation>  
<operation name="getReturnInfo">  
<soap:operation soapAction=""/>  
<input>  
<soap:body use="literal"/>  
</input>  
<output>  
<soap:body use="literal"/>  
</output>  
</operation>  
</binding>  
<service name="API">  
<port name="PortName" binding="tns:PortNameBinding">  
<soap:address location="http://localhost/fake/ws"/>  
</port>  
</service>  
</definitions>  
View Code

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • for 迴圈用於您預先知道腳本需要運行的次數的情況。 語法 參數: 初始值:主要是初始化一個變數值,用於設置一個計數器(但可以是任何在迴圈的開始被執行一次的代碼)。 條件:迴圈執行的限制條件。如果為 TRUE,則迴圈繼續。如果為 FALSE,則迴圈結束。 增量:主要用於遞增計數器(但可以是任何在迴圈 ...
  • Modal也即是模態窗,通俗的說就是彈窗。是一款bootstrap的js插件,使用效果也是非常好。 為什麼要使用modal就不必多說了,一個網站,在開發過程中你說你沒用過js彈窗我都不信!好的彈窗不僅僅給人以美感,也會讓我們開發效率提高,甚至心情也會舒暢! 我們看看在yii2中如何使用modal。 ...
  • SSH項目出現了 錯誤,仔細檢查後發現,是兩個不同的屬性映射了表中的同一個欄位造成的錯誤。 ...
  • Spring中的新名稱也太多了吧!IOC/DI/MVC/AOP/DAO/ORM... 對於剛剛接觸spring的我來說確實暈了頭!可是一但你完全掌握了一個概念,那麼它就會死心塌地的為你服務了。這可比女人忠誠多了。 在這裡我們來說侃下MVC吧!嗯!MVC設計模型和MVC框架之區別。 一組概念需要先理解 ...
  • JavaWeb不能吃。本文將帶你在JavaWeb的世界里走馬看花,踏雪尋梅,讓你明白,JavaWeb究竟是個啥。 ...
  • 1.將String字元串放在最前面 為了防止偶發性的NullPointerException 異常,我們通常將String放置在equals()函數的左邊來實現字元串比較,如下代碼: <pre http:="" www.ahlinux.com="" start="" cmd="" 9034.html ...
  • 組件配置添加: common\components\XmlParser 然後就可以在控制器里直接取 xml格式適合微信公眾號開發。 ...
  • 1.將對象轉換為JSON字元串,返回值為一個JSON字元串 public static String toJson(Object value) { try { return mapper.writeValueAsString(value); } catch (Exception e) { e.pri ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...